aboutsummaryrefslogtreecommitdiff
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
parent42676ca0f638a76369730269b5d8aa590694bcc0 (diff)
downloadsshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar.gz
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.tar.bz2
sshfs-95381c9bb467fd002e9742f426e2b036bfa3c7cc.zip
fix
-rw-r--r--ChangeLog4
-rw-r--r--cache.c1
-rw-r--r--sshfs.c28
3 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ed75569..5785b4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-08-23 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Add create() method
+
2005-08-17 Miklos Szeredi <miklos@szeredi.hu>
* Try to calculate approximate disk usage of files from their
diff --git a/cache.c b/cache.c
index 733a451..a2cfa3d 100644
--- a/cache.c
+++ b/cache.c
@@ -423,6 +423,7 @@ static void cache_unity_fill(struct fuse_cache_operations *oper,
cache_oper->chown = oper->oper.chown;
cache_oper->truncate = oper->oper.truncate;
cache_oper->utime = oper->oper.utime;
+ cache_oper->create = oper->oper.create;
cache_oper->open = oper->oper.open;
cache_oper->read = oper->oper.read;
cache_oper->write = oper->oper.write;
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,