From 8edeaa3f29b418f621542c72d77ba0c639e6d457 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 6 Jul 2011 12:12:01 +0200 Subject: 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. --- lib/modules/subdir.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/modules/subdir.c') 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, -- cgit v1.2.3