Skip to content

Commit

Permalink
vfs: add vfs_select_inode() helper
Browse files Browse the repository at this point in the history
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: <stable@vger.kernel.org> # v4.2+
  • Loading branch information
Miklos Szeredi authored and Al Viro committed May 11, 2016
1 parent 44549e8 commit 54d5ca8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 4 additions & 8 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,16 +840,12 @@ EXPORT_SYMBOL(file_path);
int vfs_open(const struct path *path, struct file *file,
const struct cred *cred)
{
struct dentry *dentry = path->dentry;
struct inode *inode = dentry->d_inode;
struct inode *inode = vfs_select_inode(path->dentry, file->f_flags);

file->f_path = *path;
if (dentry->d_flags & DCACHE_OP_SELECT_INODE) {
inode = dentry->d_op->d_select_inode(dentry, file->f_flags);
if (IS_ERR(inode))
return PTR_ERR(inode);
}
if (IS_ERR(inode))
return PTR_ERR(inode);

file->f_path = *path;
return do_dentry_open(file, inode, NULL, cred);
}

Expand Down
12 changes: 12 additions & 0 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,16 @@ static inline struct dentry *d_real(struct dentry *dentry)
return dentry;
}

static inline struct inode *vfs_select_inode(struct dentry *dentry,
unsigned open_flags)
{
struct inode *inode = d_inode(dentry);

if (inode && unlikely(dentry->d_flags & DCACHE_OP_SELECT_INODE))
inode = dentry->d_op->d_select_inode(dentry, open_flags);

return inode;
}


#endif /* __LINUX_DCACHE_H */

0 comments on commit 54d5ca8

Please sign in to comment.