diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-12-11 12:10:06 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-20 18:50:02 -0500 |
commit | 1ac12b4b6d707937f9de6d09622823b2fd0c93ef (patch) | |
tree | 7ac3f66abfcce206615abe9effd9e55f26c117a9 /fs | |
parent | 7955119e02d9fdf78a39fba8073f19ca6152613e (diff) |
vfs: turn is_dir argument to kern_path_create into a lookup_flags arg
Where we can pass in LOOKUP_DIRECTORY or LOOKUP_REVAL. Any other flags
passed in here are currently ignored.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namei.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/namei.c b/fs/namei.c index 25a41e02984b..8f8e41f6eb52 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -3030,12 +3030,22 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, | |||
3030 | return file; | 3030 | return file; |
3031 | } | 3031 | } |
3032 | 3032 | ||
3033 | struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, int is_dir) | 3033 | struct dentry *kern_path_create(int dfd, const char *pathname, |
3034 | struct path *path, unsigned int lookup_flags) | ||
3034 | { | 3035 | { |
3035 | struct dentry *dentry = ERR_PTR(-EEXIST); | 3036 | struct dentry *dentry = ERR_PTR(-EEXIST); |
3036 | struct nameidata nd; | 3037 | struct nameidata nd; |
3037 | int err2; | 3038 | int err2; |
3038 | int error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd); | 3039 | int error; |
3040 | bool is_dir = (lookup_flags & LOOKUP_DIRECTORY); | ||
3041 | |||
3042 | /* | ||
3043 | * Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any | ||
3044 | * other flags passed in are ignored! | ||
3045 | */ | ||
3046 | lookup_flags &= LOOKUP_REVAL; | ||
3047 | |||
3048 | error = do_path_lookup(dfd, pathname, LOOKUP_PARENT|lookup_flags, &nd); | ||
3039 | if (error) | 3049 | if (error) |
3040 | return ERR_PTR(error); | 3050 | return ERR_PTR(error); |
3041 | 3051 | ||
@@ -3099,13 +3109,14 @@ void done_path_create(struct path *path, struct dentry *dentry) | |||
3099 | } | 3109 | } |
3100 | EXPORT_SYMBOL(done_path_create); | 3110 | EXPORT_SYMBOL(done_path_create); |
3101 | 3111 | ||
3102 | struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir) | 3112 | struct dentry *user_path_create(int dfd, const char __user *pathname, |
3113 | struct path *path, unsigned int lookup_flags) | ||
3103 | { | 3114 | { |
3104 | struct filename *tmp = getname(pathname); | 3115 | struct filename *tmp = getname(pathname); |
3105 | struct dentry *res; | 3116 | struct dentry *res; |
3106 | if (IS_ERR(tmp)) | 3117 | if (IS_ERR(tmp)) |
3107 | return ERR_CAST(tmp); | 3118 | return ERR_CAST(tmp); |
3108 | res = kern_path_create(dfd, tmp->name, path, is_dir); | 3119 | res = kern_path_create(dfd, tmp->name, path, lookup_flags); |
3109 | putname(tmp); | 3120 | putname(tmp); |
3110 | return res; | 3121 | return res; |
3111 | } | 3122 | } |
@@ -3228,7 +3239,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode) | |||
3228 | struct path path; | 3239 | struct path path; |
3229 | int error; | 3240 | int error; |
3230 | 3241 | ||
3231 | dentry = user_path_create(dfd, pathname, &path, 1); | 3242 | dentry = user_path_create(dfd, pathname, &path, LOOKUP_DIRECTORY); |
3232 | if (IS_ERR(dentry)) | 3243 | if (IS_ERR(dentry)) |
3233 | return PTR_ERR(dentry); | 3244 | return PTR_ERR(dentry); |
3234 | 3245 | ||