diff options
author | Tejun Heo <tj@kernel.org> | 2008-11-26 06:03:55 -0500 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2008-11-26 06:03:55 -0500 |
commit | acf99433d98c2570a619d8fb8b51abce4e532059 (patch) | |
tree | 3d8c6933448ad67c4343808113c7ee8f41050349 /fs/fuse/file.c | |
parent | 59efec7b903987dcb60b9ebc85c7acd4443a11a1 (diff) |
fuse: add file kernel handle
The file handle, fuse_file->fh, is opaque value supplied by userland
FUSE server and uniqueness is not guaranteed. Add file kernel handle,
fuse_file->kh, which is allocated by the kernel on file allocation and
guaranteed to be unique.
This will be used by poll to match notification to the respective file
but can be used for other purposes where unique file handle is
necessary.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r-- | fs/fuse/file.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index baed06ea7622..a28ced678d38 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -46,7 +46,7 @@ static int fuse_send_open(struct inode *inode, struct file *file, int isdir, | |||
46 | return err; | 46 | return err; |
47 | } | 47 | } |
48 | 48 | ||
49 | struct fuse_file *fuse_file_alloc(void) | 49 | struct fuse_file *fuse_file_alloc(struct fuse_conn *fc) |
50 | { | 50 | { |
51 | struct fuse_file *ff; | 51 | struct fuse_file *ff; |
52 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); | 52 | ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL); |
@@ -58,6 +58,9 @@ struct fuse_file *fuse_file_alloc(void) | |||
58 | } else { | 58 | } else { |
59 | INIT_LIST_HEAD(&ff->write_entry); | 59 | INIT_LIST_HEAD(&ff->write_entry); |
60 | atomic_set(&ff->count, 0); | 60 | atomic_set(&ff->count, 0); |
61 | spin_lock(&fc->lock); | ||
62 | ff->kh = ++fc->khctr; | ||
63 | spin_unlock(&fc->lock); | ||
61 | } | 64 | } |
62 | } | 65 | } |
63 | return ff; | 66 | return ff; |
@@ -108,6 +111,7 @@ void fuse_finish_open(struct inode *inode, struct file *file, | |||
108 | 111 | ||
109 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) | 112 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) |
110 | { | 113 | { |
114 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
111 | struct fuse_open_out outarg; | 115 | struct fuse_open_out outarg; |
112 | struct fuse_file *ff; | 116 | struct fuse_file *ff; |
113 | int err; | 117 | int err; |
@@ -120,7 +124,7 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir) | |||
120 | if (err) | 124 | if (err) |
121 | return err; | 125 | return err; |
122 | 126 | ||
123 | ff = fuse_file_alloc(); | 127 | ff = fuse_file_alloc(fc); |
124 | if (!ff) | 128 | if (!ff) |
125 | return -ENOMEM; | 129 | return -ENOMEM; |
126 | 130 | ||