mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 12:52:30 +00:00
namei.c: get rid of user_path_parent()
direct use of filename_parentat() is just as readable Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e5517c2a5a
commit
c1d4dd2767
34
fs/namei.c
34
fs/namei.c
@ -2558,24 +2558,6 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(user_path_at_empty);
|
EXPORT_SYMBOL(user_path_at_empty);
|
||||||
|
|
||||||
/*
|
|
||||||
* NB: most callers don't do anything directly with the reference to the
|
|
||||||
* to struct filename, but the nd->last pointer points into the name string
|
|
||||||
* allocated by getname. So we must hold the reference to it until all
|
|
||||||
* path-walking is complete.
|
|
||||||
*/
|
|
||||||
static inline struct filename *
|
|
||||||
user_path_parent(int dfd, const char __user *path,
|
|
||||||
struct path *parent,
|
|
||||||
struct qstr *last,
|
|
||||||
int *type,
|
|
||||||
unsigned int flags)
|
|
||||||
{
|
|
||||||
/* only LOOKUP_REVAL is allowed in extra flags */
|
|
||||||
return filename_parentat(dfd, getname(path), flags & LOOKUP_REVAL,
|
|
||||||
parent, last, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mountpoint_last - look up last component for umount
|
* mountpoint_last - look up last component for umount
|
||||||
* @nd: pathwalk nameidata - currently pointing at parent directory of "last"
|
* @nd: pathwalk nameidata - currently pointing at parent directory of "last"
|
||||||
@ -3861,8 +3843,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
|
|||||||
int type;
|
int type;
|
||||||
unsigned int lookup_flags = 0;
|
unsigned int lookup_flags = 0;
|
||||||
retry:
|
retry:
|
||||||
name = user_path_parent(dfd, pathname,
|
name = filename_parentat(dfd, getname(pathname), lookup_flags,
|
||||||
&path, &last, &type, lookup_flags);
|
&path, &last, &type);
|
||||||
if (IS_ERR(name))
|
if (IS_ERR(name))
|
||||||
return PTR_ERR(name);
|
return PTR_ERR(name);
|
||||||
|
|
||||||
@ -3991,8 +3973,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
|
|||||||
struct inode *delegated_inode = NULL;
|
struct inode *delegated_inode = NULL;
|
||||||
unsigned int lookup_flags = 0;
|
unsigned int lookup_flags = 0;
|
||||||
retry:
|
retry:
|
||||||
name = user_path_parent(dfd, pathname,
|
name = filename_parentat(dfd, getname(pathname), lookup_flags,
|
||||||
&path, &last, &type, lookup_flags);
|
&path, &last, &type);
|
||||||
if (IS_ERR(name))
|
if (IS_ERR(name))
|
||||||
return PTR_ERR(name);
|
return PTR_ERR(name);
|
||||||
|
|
||||||
@ -4491,15 +4473,15 @@ SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname,
|
|||||||
target_flags = 0;
|
target_flags = 0;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
from = user_path_parent(olddfd, oldname,
|
from = filename_parentat(olddfd, getname(oldname), lookup_flags,
|
||||||
&old_path, &old_last, &old_type, lookup_flags);
|
&old_path, &old_last, &old_type);
|
||||||
if (IS_ERR(from)) {
|
if (IS_ERR(from)) {
|
||||||
error = PTR_ERR(from);
|
error = PTR_ERR(from);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
to = user_path_parent(newdfd, newname,
|
to = filename_parentat(newdfd, getname(newname), lookup_flags,
|
||||||
&new_path, &new_last, &new_type, lookup_flags);
|
&new_path, &new_last, &new_type);
|
||||||
if (IS_ERR(to)) {
|
if (IS_ERR(to)) {
|
||||||
error = PTR_ERR(to);
|
error = PTR_ERR(to);
|
||||||
goto exit1;
|
goto exit1;
|
||||||
|
Loading…
Reference in New Issue
Block a user