diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2011-07-06 12:12:01 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2011-07-06 12:12:01 +0200 |
commit | 8edeaa3f29b418f621542c72d77ba0c639e6d457 (patch) | |
tree | 2ed1297e688d1f37c7b92ce09dfb38025066900c /lib/modules | |
parent | c605b5f73c458eeacdb6653e6899b5ebe7f1fc1a (diff) | |
download | libfuse-8edeaa3f29b418f621542c72d77ba0c639e6d457.tar.gz |
Add ->flock() operation to low and high level interfaces
This fixes problems with emulating flock() with POSIX locking.
Reported by Sebastian Pipping.
As with lock/setlk/getlk most filesystems don't need to implement
this, as the kernel takes care of file locking. The only reason to
implement locking operations is for network filesystems which want
file locking to work between clients.
Diffstat (limited to 'lib/modules')
-rw-r--r-- | lib/modules/iconv.c | 13 | ||||
-rw-r--r-- | lib/modules/subdir.c | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/modules/iconv.c b/lib/modules/iconv.c index b9946d9..1b78192 100644 --- a/lib/modules/iconv.c +++ b/lib/modules/iconv.c @@ -549,6 +549,18 @@ static int iconv_lock(const char *path, struct fuse_file_info *fi, int cmd, return err; } +static int iconv_flock(const char *path, struct fuse_file_info *fi, int op) +{ + struct iconv *ic = iconv_get(); + char *newpath; + int err = iconv_convpath(ic, path, &newpath, 0); + if (!err) { + err = fuse_fs_flock(ic->next, newpath, fi, op); + free(newpath); + } + return err; +} + static int iconv_bmap(const char *path, size_t blocksize, uint64_t *idx) { struct iconv *ic = iconv_get(); @@ -616,6 +628,7 @@ static struct fuse_operations iconv_oper = { .listxattr = iconv_listxattr, .removexattr = iconv_removexattr, .lock = iconv_lock, + .flock = iconv_flock, .bmap = iconv_bmap, .flag_nullpath_ok = 1, diff --git a/lib/modules/subdir.c b/lib/modules/subdir.c index 6d9ac89..24dede6 100644 --- a/lib/modules/subdir.c +++ b/lib/modules/subdir.c @@ -536,6 +536,18 @@ static int subdir_lock(const char *path, struct fuse_file_info *fi, int cmd, return err; } +static int subdir_flock(const char *path, struct fuse_file_info *fi, int op) +{ + struct subdir *d = subdir_get(); + char *newpath; + int err = subdir_addpath(d, path, &newpath); + if (!err) { + err = fuse_fs_flock(d->next, newpath, fi, op); + free(newpath); + } + return err; +} + static int subdir_bmap(const char *path, size_t blocksize, uint64_t *idx) { struct subdir *d = subdir_get(); @@ -599,6 +611,7 @@ static struct fuse_operations subdir_oper = { .listxattr = subdir_listxattr, .removexattr = subdir_removexattr, .lock = subdir_lock, + .flock = subdir_flock, .bmap = subdir_bmap, .flag_nullpath_ok = 1, |