Commit 20955e89 authored by Stephen Boyd's avatar Stephen Boyd Committed by Linus Torvalds

libfs: add simple_open()

debugfs and a few other drivers use an open-coded version of
simple_open() to pass a pointer from the file to the read/write file
ops.  Add support for this simple case to libfs so that we can remove
the many duplicate copies of this simple function.
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7563ec4c
...@@ -264,6 +264,13 @@ struct dentry *mount_pseudo(struct file_system_type *fs_type, char *name, ...@@ -264,6 +264,13 @@ struct dentry *mount_pseudo(struct file_system_type *fs_type, char *name,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
int simple_open(struct inode *inode, struct file *file)
{
if (inode->i_private)
file->private_data = inode->i_private;
return 0;
}
int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) int simple_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
{ {
struct inode *inode = old_dentry->d_inode; struct inode *inode = old_dentry->d_inode;
...@@ -984,6 +991,7 @@ EXPORT_SYMBOL(simple_dir_operations); ...@@ -984,6 +991,7 @@ EXPORT_SYMBOL(simple_dir_operations);
EXPORT_SYMBOL(simple_empty); EXPORT_SYMBOL(simple_empty);
EXPORT_SYMBOL(simple_fill_super); EXPORT_SYMBOL(simple_fill_super);
EXPORT_SYMBOL(simple_getattr); EXPORT_SYMBOL(simple_getattr);
EXPORT_SYMBOL(simple_open);
EXPORT_SYMBOL(simple_link); EXPORT_SYMBOL(simple_link);
EXPORT_SYMBOL(simple_lookup); EXPORT_SYMBOL(simple_lookup);
EXPORT_SYMBOL(simple_pin_fs); EXPORT_SYMBOL(simple_pin_fs);
......
...@@ -2502,6 +2502,7 @@ extern int dcache_readdir(struct file *, void *, filldir_t); ...@@ -2502,6 +2502,7 @@ extern int dcache_readdir(struct file *, void *, filldir_t);
extern int simple_setattr(struct dentry *, struct iattr *); extern int simple_setattr(struct dentry *, struct iattr *);
extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
extern int simple_statfs(struct dentry *, struct kstatfs *); extern int simple_statfs(struct dentry *, struct kstatfs *);
extern int simple_open(struct inode *inode, struct file *file);
extern int simple_link(struct dentry *, struct inode *, struct dentry *); extern int simple_link(struct dentry *, struct inode *, struct dentry *);
extern int simple_unlink(struct inode *, struct dentry *); extern int simple_unlink(struct inode *, struct dentry *);
extern int simple_rmdir(struct inode *, struct dentry *); extern int simple_rmdir(struct inode *, struct dentry *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment