mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
new helper: user_path_locked_at()
Equivalent of kern_path_locked() taking dfd/userland name. User introduced in the next commit. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b85ea95d08
commit
74d016ecc1
2 changed files with 14 additions and 3 deletions
16
fs/namei.c
16
fs/namei.c
|
@ -2573,13 +2573,13 @@ static int filename_parentat(int dfd, struct filename *name,
|
|||
}
|
||||
|
||||
/* does lookup, returns the object with parent locked */
|
||||
static struct dentry *__kern_path_locked(struct filename *name, struct path *path)
|
||||
static struct dentry *__kern_path_locked(int dfd, struct filename *name, struct path *path)
|
||||
{
|
||||
struct dentry *d;
|
||||
struct qstr last;
|
||||
int type, error;
|
||||
|
||||
error = filename_parentat(AT_FDCWD, name, 0, path, &last, &type);
|
||||
error = filename_parentat(dfd, name, 0, path, &last, &type);
|
||||
if (error)
|
||||
return ERR_PTR(error);
|
||||
if (unlikely(type != LAST_NORM)) {
|
||||
|
@ -2598,12 +2598,22 @@ static struct dentry *__kern_path_locked(struct filename *name, struct path *pat
|
|||
struct dentry *kern_path_locked(const char *name, struct path *path)
|
||||
{
|
||||
struct filename *filename = getname_kernel(name);
|
||||
struct dentry *res = __kern_path_locked(filename, path);
|
||||
struct dentry *res = __kern_path_locked(AT_FDCWD, filename, path);
|
||||
|
||||
putname(filename);
|
||||
return res;
|
||||
}
|
||||
|
||||
struct dentry *user_path_locked_at(int dfd, const char __user *name, struct path *path)
|
||||
{
|
||||
struct filename *filename = getname(name);
|
||||
struct dentry *res = __kern_path_locked(dfd, filename, path);
|
||||
|
||||
putname(filename);
|
||||
return res;
|
||||
}
|
||||
EXPORT_SYMBOL(user_path_locked_at);
|
||||
|
||||
int kern_path(const char *name, unsigned int flags, struct path *path)
|
||||
{
|
||||
struct filename *filename = getname_kernel(name);
|
||||
|
|
|
@ -66,6 +66,7 @@ extern struct dentry *kern_path_create(int, const char *, struct path *, unsigne
|
|||
extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
|
||||
extern void done_path_create(struct path *, struct dentry *);
|
||||
extern struct dentry *kern_path_locked(const char *, struct path *);
|
||||
extern struct dentry *user_path_locked_at(int , const char __user *, struct path *);
|
||||
int vfs_path_parent_lookup(struct filename *filename, unsigned int flags,
|
||||
struct path *parent, struct qstr *last, int *type,
|
||||
const struct path *root);
|
||||
|
|
Loading…
Reference in a new issue