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 | |
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>
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/syscalls.c | 2 | ||||
-rw-r--r-- | drivers/base/devtmpfs.c | 2 | ||||
-rw-r--r-- | fs/namei.c | 21 | ||||
-rw-r--r-- | include/linux/namei.h | 4 |
4 files changed, 20 insertions, 9 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c index 5b7d8ffbf890..baee994fe810 100644 --- a/arch/powerpc/platforms/cell/spufs/syscalls.c +++ b/arch/powerpc/platforms/cell/spufs/syscalls.c | |||
@@ -66,7 +66,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags, | |||
66 | struct dentry *dentry; | 66 | struct dentry *dentry; |
67 | int ret; | 67 | int ret; |
68 | 68 | ||
69 | dentry = user_path_create(AT_FDCWD, pathname, &path, 1); | 69 | dentry = user_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY); |
70 | ret = PTR_ERR(dentry); | 70 | ret = PTR_ERR(dentry); |
71 | if (!IS_ERR(dentry)) { | 71 | if (!IS_ERR(dentry)) { |
72 | ret = spufs_create(&path, dentry, flags, mode, neighbor); | 72 | ret = spufs_create(&path, dentry, flags, mode, neighbor); |
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 147d1a4dd269..17cf7cad601e 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
@@ -148,7 +148,7 @@ static int dev_mkdir(const char *name, umode_t mode) | |||
148 | struct path path; | 148 | struct path path; |
149 | int err; | 149 | int err; |
150 | 150 | ||
151 | dentry = kern_path_create(AT_FDCWD, name, &path, 1); | 151 | dentry = kern_path_create(AT_FDCWD, name, &path, LOOKUP_DIRECTORY); |
152 | if (IS_ERR(dentry)) | 152 | if (IS_ERR(dentry)) |
153 | return PTR_ERR(dentry); | 153 | return PTR_ERR(dentry); |
154 | 154 | ||
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 | ||
diff --git a/include/linux/namei.h b/include/linux/namei.h index 66542b644804..e998c030061d 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h | |||
@@ -65,8 +65,8 @@ extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, | |||
65 | 65 | ||
66 | extern int kern_path(const char *, unsigned, struct path *); | 66 | extern int kern_path(const char *, unsigned, struct path *); |
67 | 67 | ||
68 | extern struct dentry *kern_path_create(int, const char *, struct path *, int); | 68 | extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int); |
69 | extern struct dentry *user_path_create(int, const char __user *, struct path *, int); | 69 | extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int); |
70 | extern void done_path_create(struct path *, struct dentry *); | 70 | extern void done_path_create(struct path *, struct dentry *); |
71 | extern struct dentry *kern_path_locked(const char *, struct path *); | 71 | extern struct dentry *kern_path_locked(const char *, struct path *); |
72 | extern int vfs_path_lookup(struct dentry *, struct vfsmount *, | 72 | extern int vfs_path_lookup(struct dentry *, struct vfsmount *, |