diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-11 12:08:24 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-14 09:15:28 -0400 |
commit | 73d049a40fc6269189c4e2ba6792cb5dd054883c (patch) | |
tree | a713747cd06926ad89bfa9b36ea13dd20bbc507f /fs/open.c | |
parent | 5b6ca027d85b7438c84b78a54ccdc2e53f2909cd (diff) |
open-style analog of vfs_path_lookup()
new function: file_open_root(dentry, mnt, name, flags) opens the file
vfs_path_lookup would arrive to.
Note that name can be empty; in that case the usual requirement that
dentry should be a directory is lifted.
open-coded equivalents switched to it, may_open() got down exactly
one caller and became static.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -959,6 +959,20 @@ struct file *filp_open(const char *filename, int flags, int mode) | |||
959 | } | 959 | } |
960 | EXPORT_SYMBOL(filp_open); | 960 | EXPORT_SYMBOL(filp_open); |
961 | 961 | ||
962 | struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, | ||
963 | const char *filename, int flags) | ||
964 | { | ||
965 | struct open_flags op; | ||
966 | int lookup = build_open_flags(flags, 0, &op); | ||
967 | if (flags & O_CREAT) | ||
968 | return ERR_PTR(-EINVAL); | ||
969 | if (!filename && (flags & O_DIRECTORY)) | ||
970 | if (!dentry->d_inode->i_op->lookup) | ||
971 | return ERR_PTR(-ENOTDIR); | ||
972 | return do_file_open_root(dentry, mnt, filename, &op, lookup); | ||
973 | } | ||
974 | EXPORT_SYMBOL(file_open_root); | ||
975 | |||
962 | long do_sys_open(int dfd, const char __user *filename, int flags, int mode) | 976 | long do_sys_open(int dfd, const char __user *filename, int flags, int mode) |
963 | { | 977 | { |
964 | struct open_flags op; | 978 | struct open_flags op; |