diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2012-05-14 13:06:13 +0200 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2012-06-20 20:14:17 -0600 |
commit | 1d6825fb1c70f6b098968342c999faac85d08995 (patch) | |
tree | 5bca0aa75e2f5f3b86f20063524e9d6a6811fc9b /fs | |
parent | ba6edfe308c2052b9826112d56d0efa3627a09c9 (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>
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 98fe2e4db87..0ca1ec017cb 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); |