提交 fa14a0b8 编写于 作者: A Al Viro

cut down the number of do_path_lookup() callers

... and don't bother with new struct filename when we already have one
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 b1940cd2
...@@ -2046,7 +2046,8 @@ struct dentry *kern_path_locked(const char *name, struct path *path) ...@@ -2046,7 +2046,8 @@ struct dentry *kern_path_locked(const char *name, struct path *path)
{ {
struct nameidata nd; struct nameidata nd;
struct dentry *d; struct dentry *d;
int err = do_path_lookup(AT_FDCWD, name, LOOKUP_PARENT, &nd); struct filename filename = {.name = name};
int err = filename_lookup(AT_FDCWD, &filename, LOOKUP_PARENT, &nd);
if (err) if (err)
return ERR_PTR(err); return ERR_PTR(err);
if (nd.last_type != LAST_NORM) { if (nd.last_type != LAST_NORM) {
...@@ -3290,7 +3291,7 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, ...@@ -3290,7 +3291,7 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
return file; return file;
} }
struct dentry *kern_path_create(int dfd, const char *pathname, static struct dentry *filename_create(int dfd, struct filename *name,
struct path *path, unsigned int lookup_flags) struct path *path, unsigned int lookup_flags)
{ {
struct dentry *dentry = ERR_PTR(-EEXIST); struct dentry *dentry = ERR_PTR(-EEXIST);
...@@ -3305,7 +3306,7 @@ struct dentry *kern_path_create(int dfd, const char *pathname, ...@@ -3305,7 +3306,7 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
*/ */
lookup_flags &= LOOKUP_REVAL; lookup_flags &= LOOKUP_REVAL;
error = do_path_lookup(dfd, pathname, LOOKUP_PARENT|lookup_flags, &nd); error = filename_lookup(dfd, name, LOOKUP_PARENT|lookup_flags, &nd);
if (error) if (error)
return ERR_PTR(error); return ERR_PTR(error);
...@@ -3359,6 +3360,13 @@ struct dentry *kern_path_create(int dfd, const char *pathname, ...@@ -3359,6 +3360,13 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
path_put(&nd.path); path_put(&nd.path);
return dentry; return dentry;
} }
struct dentry *kern_path_create(int dfd, const char *pathname,
struct path *path, unsigned int lookup_flags)
{
struct filename filename = {.name = pathname};
return filename_create(dfd, &filename, path, lookup_flags);
}
EXPORT_SYMBOL(kern_path_create); EXPORT_SYMBOL(kern_path_create);
void done_path_create(struct path *path, struct dentry *dentry) void done_path_create(struct path *path, struct dentry *dentry)
...@@ -3377,7 +3385,7 @@ struct dentry *user_path_create(int dfd, const char __user *pathname, ...@@ -3377,7 +3385,7 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
struct dentry *res; struct dentry *res;
if (IS_ERR(tmp)) if (IS_ERR(tmp))
return ERR_CAST(tmp); return ERR_CAST(tmp);
res = kern_path_create(dfd, tmp->name, path, lookup_flags); res = filename_create(dfd, tmp, path, lookup_flags);
putname(tmp); putname(tmp);
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册