aboutsummaryrefslogtreecommitdiff
path: root/sshfs.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-08-23 15:41:02 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-08-23 15:41:02 +0000
commit95381c9bb467fd002e9742f426e2b036bfa3c7cc (patch)
treeebbef130b6e617ca89bc6d549b6145583d72602b /sshfs.c
parent42676ca0f638a76369730269b5d8aa590694bcc0 (diff)
downloadsshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar.gz
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar.bz2
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.zip
fix
Diffstat (limited to 'sshfs.c')
-rw-r--r--sshfs.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/sshfs.c b/sshfs.c
index 758d604..7491763 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -1282,7 +1282,8 @@ static inline int sshfs_file_is_conn(struct sshfs_file *sf)
return sf->connver == connver;
}
-static int sshfs_open(const char *path, struct fuse_file_info *fi)
+static int sshfs_open_common(const char *path, mode_t mode,
+ struct fuse_file_info *fi)
{
int err;
struct buffer buf;
@@ -1297,6 +1298,12 @@ static int sshfs_open(const char *path, struct fuse_file_info *fi)
else
return -EINVAL;
+ if (fi->flags & O_CREAT)
+ pflags |= SSH_FXF_CREAT;
+
+ if (fi->flags & O_EXCL)
+ pflags |= SSH_FXF_EXCL;
+
sf = g_new0(struct sshfs_file, 1);
list_init(&sf->write_reqs);
pthread_cond_init(&sf->write_finished, NULL);
@@ -1307,7 +1314,8 @@ static int sshfs_open(const char *path, struct fuse_file_info *fi)
buf_init(&buf, 0);
buf_add_path(&buf, path);
buf_add_uint32(&buf, pflags);
- buf_add_uint32(&buf, 0);
+ buf_add_uint32(&buf, SSH_FILEXFER_ATTR_PERMISSIONS);
+ buf_add_uint32(&buf, mode);
err = sftp_request(SSH_FXP_OPEN, &buf, SSH_FXP_HANDLE, &sf->handle);
if (!err) {
buf_finish(&sf->handle);
@@ -1318,6 +1326,19 @@ static int sshfs_open(const char *path, struct fuse_file_info *fi)
return err;
}
+#if FUSE_VERSION >= 24
+static int sshfs_create(const char *path, mode_t mode,
+ struct fuse_file_info *fi)
+{
+ return sshfs_open_common(path, mode, fi);
+}
+#endif
+
+static int sshfs_open(const char *path, struct fuse_file_info *fi)
+{
+ return sshfs_open_common(path, 0, fi);
+}
+
static int sshfs_flush(const char *path, struct fuse_file_info *fi)
{
int err;
@@ -1653,6 +1674,9 @@ static struct fuse_cache_operations sshfs_oper = {
.chown = sshfs_chown,
.truncate = sshfs_truncate,
.utime = sshfs_utime,
+#if FUSE_VERSION >= 24
+ .create = sshfs_create,
+#endif
.open = sshfs_open,
.flush = sshfs_flush,
.fsync = sshfs_fsync,