diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2011-12-21 18:19:21 +0100 |
---|---|---|
committer | Tim Gardner <tim.gardner@canonical.com> | 2012-03-19 11:29:24 -0600 |
commit | 23e52e6a97618d96d999bd6a18f68ab3c28aebec (patch) | |
tree | 69a7dda2546690d98e938b355d3942a3894548d1 /fs | |
parent | 67d654a677f4120579d6081b5112c75ee275cb14 (diff) |
UBUNTU: ubuntu: overlayfs -- vfs: add i_op->open()
Add a new inode operation i_op->open(). This is for stacked
filesystems that want to return a struct file from a different
filesystem.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/open.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/fs/open.c b/fs/open.c index f75e70b1fcf..892c386b852 100644 --- a/fs/open.c +++ b/fs/open.c @@ -800,7 +800,7 @@ struct file *nameidata_to_filp(struct nameidata *nd) /* Has the filesystem initialised the file for us? */ if (filp->f_path.dentry == NULL) - filp = __dentry_open(&nd->path, filp, NULL, cred); + filp = vfs_open(&nd->path, filp, cred); return filp; } @@ -825,7 +825,7 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, f = get_empty_filp(); if (f != NULL) { f->f_flags = flags; - ret = __dentry_open(&path, f, NULL, cred); + ret = vfs_open(&path, f, cred); } path_put(&path); @@ -833,6 +833,27 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, } EXPORT_SYMBOL(dentry_open); +/** + * vfs_open - open the file at the given path + * @path: path to open + * @filp: newly allocated file with f_flag initialized + * @cred: credentials to use + * + * Open the file. If successful, the returned file will have acquired + * an additional reference for path. + */ +struct file *vfs_open(struct path *path, struct file *filp, + const struct cred *cred) +{ + struct inode *inode = path->dentry->d_inode; + + if (inode->i_op->open) + return inode->i_op->open(path->dentry, filp, cred); + else + return __dentry_open(path, filp, NULL, cred); +} +EXPORT_SYMBOL(vfs_open); + static void __put_unused_fd(struct files_struct *files, unsigned int fd) { struct fdtable *fdt = files_fdtable(files); |