summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-10-17 11:48:52 +1100
committerDamien Miller <djm@mindrot.org>2013-10-17 11:48:52 +1100
commitf29238e67471a7f1088a99c3c3dbafce76b790cf (patch)
tree39ea232a72df52b4adbc3affea0108d8b0f45b42 /sftp-server.c
parent51682faa599550a69d8120e5e2bdbdc0625ef4be (diff)
- djm@cvs.openbsd.org 2013/10/17 00:30:13
[PROTOCOL sftp-client.c sftp-client.h sftp-server.c sftp.1 sftp.c] fsync@openssh.com protocol extension for sftp-server client support to allow calling fsync() faster successful transfer patch mostly by imorgan AT nas.nasa.gov; bz#1798 "fine" markus@ "grumble OK" deraadt@ "doesn't sound bad to me" millert@
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sftp-server.c b/sftp-server.c
index 3056c454..ad158f8e 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-server.c,v 1.101 2013/10/14 23:28:23 djm Exp $ */
+/* $OpenBSD: sftp-server.c,v 1.102 2013/10/17 00:30:13 djm Exp $ */
/*
* Copyright (c) 2000-2004 Markus Friedl. All rights reserved.
*
@@ -112,6 +112,7 @@ static void process_extended_posix_rename(u_int32_t id);
static void process_extended_statvfs(u_int32_t id);
static void process_extended_fstatvfs(u_int32_t id);
static void process_extended_hardlink(u_int32_t id);
+static void process_extended_fsync(u_int32_t id);
static void process_extended(u_int32_t id);
struct sftp_handler {
@@ -152,6 +153,7 @@ struct sftp_handler extended_handlers[] = {
{ "statvfs", "statvfs@openssh.com", 0, process_extended_statvfs, 0 },
{ "fstatvfs", "fstatvfs@openssh.com", 0, process_extended_fstatvfs, 0 },
{ "hardlink", "hardlink@openssh.com", 0, process_extended_hardlink, 1 },
+ { "fsync", "fsync@openssh.com", 0, process_extended_fsync, 1 },
{ NULL, NULL, 0, NULL, 0 }
};
@@ -652,6 +654,9 @@ process_init(void)
/* hardlink extension */
buffer_put_cstring(&msg, "hardlink@openssh.com");
buffer_put_cstring(&msg, "1"); /* version */
+ /* fsync extension */
+ buffer_put_cstring(&msg, "fsync@openssh.com");
+ buffer_put_cstring(&msg, "1"); /* version */
send_msg(&msg);
buffer_free(&msg);
}
@@ -1298,6 +1303,23 @@ process_extended_hardlink(u_int32_t id)
}
static void
+process_extended_fsync(u_int32_t id)
+{
+ int handle, fd, ret, status = SSH2_FX_OP_UNSUPPORTED;
+
+ handle = get_handle();
+ debug3("request %u: fsync (handle %u)", id, handle);
+ verbose("fsync \"%s\"", handle_to_name(handle));
+ if ((fd = handle_to_fd(handle)) < 0)
+ status = SSH2_FX_NO_SUCH_FILE;
+ else if (handle_is_ok(handle, HANDLE_FILE)) {
+ ret = fsync(fd);
+ status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
+ }
+ send_status(id, status);
+}
+
+static void
process_extended(u_int32_t id)
{
char *request;