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>
This commit is contained in:
committed by
Miklos Szeredi
parent
59efec7b90
commit
acf99433d9
@ -46,7 +46,7 @@ static int fuse_send_open(struct inode *inode, struct file *file, int isdir,
|
||||
return err;
|
||||
}
|
||||
|
||||
struct fuse_file *fuse_file_alloc(void)
|
||||
struct fuse_file *fuse_file_alloc(struct fuse_conn *fc)
|
||||
{
|
||||
struct fuse_file *ff;
|
||||
ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
|
||||
@ -58,6 +58,9 @@ struct fuse_file *fuse_file_alloc(void)
|
||||
} else {
|
||||
INIT_LIST_HEAD(&ff->write_entry);
|
||||
atomic_set(&ff->count, 0);
|
||||
spin_lock(&fc->lock);
|
||||
ff->kh = ++fc->khctr;
|
||||
spin_unlock(&fc->lock);
|
||||
}
|
||||
}
|
||||
return ff;
|
||||
@ -108,6 +111,7 @@ void fuse_finish_open(struct inode *inode, struct file *file,
|
||||
|
||||
int fuse_open_common(struct inode *inode, struct file *file, int isdir)
|
||||
{
|
||||
struct fuse_conn *fc = get_fuse_conn(inode);
|
||||
struct fuse_open_out outarg;
|
||||
struct fuse_file *ff;
|
||||
int err;
|
||||
@ -120,7 +124,7 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ff = fuse_file_alloc();
|
||||
ff = fuse_file_alloc(fc);
|
||||
if (!ff)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Reference in New Issue
Block a user