aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
authorRian Hunter <rian@alum.mit.edu>2016-06-01 22:30:44 -0700
committerRian Hunter <rian@alum.mit.edu>2016-06-01 22:34:36 -0700
commit0f6f33b1b4084426a78035788e5e8502a3dc5af0 (patch)
treef5efd5951579e0cb3cfc363947de02391d60c0db /sshfs.c
parenta9a1cc004675f35df34c68f3e134c2194311943f (diff)
downloadsshfs-0f6f33b1b4084426a78035788e5e8502a3dc5af0.tar
sshfs-0f6f33b1b4084426a78035788e5e8502a3dc5af0.tar.gz
sshfs-0f6f33b1b4084426a78035788e5e8502a3dc5af0.tar.bz2
sshfs-0f6f33b1b4084426a78035788e5e8502a3dc5af0.zip
Implement support for "fsync@openssh.com"
OpenSSH implements fsync() via the extension "fsync@openssh.com". This change uses that extension when receiving a FUSE fsync request.
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sshfs.c b/sshfs.c
index ce30a0f..9fb68af 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -118,6 +118,7 @@
#define SFTP_EXT_POSIX_RENAME "posix-rename@openssh.com"
#define SFTP_EXT_STATVFS "statvfs@openssh.com"
#define SFTP_EXT_HARDLINK "hardlink@openssh.com"
+#define SFTP_EXT_FSYNC "fsync@openssh.com"
#define PROTO_VERSION 3
@@ -273,6 +274,7 @@ struct sshfs {
int ext_posix_rename;
int ext_statvfs;
int ext_hardlink;
+ int ext_fsync;
mode_t mnt_mode;
struct fuse_operations *op;
@@ -1548,6 +1550,9 @@ static int sftp_init_reply_ok(struct buffer *buf, uint32_t *version)
if (strcmp(ext, SFTP_EXT_HARDLINK) == 0 &&
strcmp(extdata, "1") == 0)
sshfs.ext_hardlink = 1;
+ if (strcmp(ext, SFTP_EXT_FSYNC) == 0 &&
+ strcmp(extdata, "1") == 0)
+ sshfs.ext_fsync = 1;
} while (buf2.len < buf2.size);
buf_free(&buf2);
}
@@ -2632,8 +2637,25 @@ static int sshfs_flush(const char *path, struct fuse_file_info *fi)
static int sshfs_fsync(const char *path, int isdatasync,
struct fuse_file_info *fi)
{
+ int err;
(void) isdatasync;
- return sshfs_flush(path, fi);
+
+ if (err = sshfs_flush(path, fi))
+ return err;
+
+ if (!sshfs.ext_fsync)
+ return err;
+
+ {
+ struct buffer buf;
+ struct sshfs_file *sf = get_sshfs_file(fi);
+ buf_init(&buf, 0);
+ buf_add_string(&buf, SFTP_EXT_FSYNC);
+ buf_add_buf(&buf, &sf->handle);
+ err = sftp_request(SSH_FXP_EXTENDED, &buf, SSH_FXP_STATUS, NULL);
+ buf_free(&buf);
+ return err;
+ }
}
static void sshfs_file_put(struct sshfs_file *sf)