aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse/inode.c
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-06-25 08:48:52 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-25 13:01:19 -0400
commit7142125937e1482ad3ae4366594c6586153dfc86 (patch)
tree8d85908a36485df0c80de2032e7fcfa493621fe4 /fs/fuse/inode.c
parentbafa96541b250a7051e3fbc5de6e8369daf8ffec (diff)
[PATCH] fuse: add POSIX file locking support
This patch adds POSIX file locking support to the fuse interface. This implementation doesn't keep any locking state in kernel. Unlocking on close() is handled by the FLUSH message, which now contains the lock owner id. Mandatory locking is not supported. The filesystem may enfoce mandatory locking in userspace if needed. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fuse/inode.c')
-rw-r--r--fs/fuse/inode.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 13a7e8ab7a78..412892905838 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -98,6 +98,14 @@ static void fuse_clear_inode(struct inode *inode)
98 } 98 }
99} 99}
100 100
101static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
102{
103 if (*flags & MS_MANDLOCK)
104 return -EINVAL;
105
106 return 0;
107}
108
101void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr) 109void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
102{ 110{
103 if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size) 111 if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
@@ -409,6 +417,7 @@ static struct super_operations fuse_super_operations = {
409 .destroy_inode = fuse_destroy_inode, 417 .destroy_inode = fuse_destroy_inode,
410 .read_inode = fuse_read_inode, 418 .read_inode = fuse_read_inode,
411 .clear_inode = fuse_clear_inode, 419 .clear_inode = fuse_clear_inode,
420 .remount_fs = fuse_remount_fs,
412 .put_super = fuse_put_super, 421 .put_super = fuse_put_super,
413 .umount_begin = fuse_umount_begin, 422 .umount_begin = fuse_umount_begin,
414 .statfs = fuse_statfs, 423 .statfs = fuse_statfs,
@@ -428,8 +437,12 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
428 ra_pages = arg->max_readahead / PAGE_CACHE_SIZE; 437 ra_pages = arg->max_readahead / PAGE_CACHE_SIZE;
429 if (arg->flags & FUSE_ASYNC_READ) 438 if (arg->flags & FUSE_ASYNC_READ)
430 fc->async_read = 1; 439 fc->async_read = 1;
431 } else 440 if (!(arg->flags & FUSE_POSIX_LOCKS))
441 fc->no_lock = 1;
442 } else {
432 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 443 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
444 fc->no_lock = 1;
445 }
433 446
434 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); 447 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
435 fc->minor = arg->minor; 448 fc->minor = arg->minor;
@@ -447,7 +460,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
447 arg->major = FUSE_KERNEL_VERSION; 460 arg->major = FUSE_KERNEL_VERSION;
448 arg->minor = FUSE_KERNEL_MINOR_VERSION; 461 arg->minor = FUSE_KERNEL_MINOR_VERSION;
449 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 462 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
450 arg->flags |= FUSE_ASYNC_READ; 463 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS;
451 req->in.h.opcode = FUSE_INIT; 464 req->in.h.opcode = FUSE_INIT;
452 req->in.numargs = 1; 465 req->in.numargs = 1;
453 req->in.args[0].size = sizeof(*arg); 466 req->in.args[0].size = sizeof(*arg);
@@ -479,6 +492,9 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
479 struct fuse_req *init_req; 492 struct fuse_req *init_req;
480 int err; 493 int err;
481 494
495 if (sb->s_flags & MS_MANDLOCK)
496 return -EINVAL;
497
482 if (!parse_fuse_opt((char *) data, &d)) 498 if (!parse_fuse_opt((char *) data, &d))
483 return -EINVAL; 499 return -EINVAL;
484 500