Skip to content

Commit b4a4f21

Browse files
brenns10Al Viro
authored andcommitted
namei: Standardize callers of filename_create()
filename_create() has two variants, one which drops the caller's reference to filename (filename_create) and one which does not (__filename_create). This can be confusing as it's unusual to drop a caller's reference. Remove filename_create, rename __filename_create to filename_create, and convert all callers. Link: https://lore.kernel.org/linux-fsdevel/[email protected]/ Cc: Christoph Hellwig <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Stephen Brennan <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 794ebce commit b4a4f21

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

fs/namei.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3620,8 +3620,8 @@ struct file *do_file_open_root(const struct path *root,
36203620
return file;
36213621
}
36223622

3623-
static struct dentry *__filename_create(int dfd, struct filename *name,
3624-
struct path *path, unsigned int lookup_flags)
3623+
static struct dentry *filename_create(int dfd, struct filename *name,
3624+
struct path *path, unsigned int lookup_flags)
36253625
{
36263626
struct dentry *dentry = ERR_PTR(-EEXIST);
36273627
struct qstr last;
@@ -3689,21 +3689,15 @@ static struct dentry *__filename_create(int dfd, struct filename *name,
36893689
return dentry;
36903690
}
36913691

3692-
static inline struct dentry *filename_create(int dfd, struct filename *name,
3692+
struct dentry *kern_path_create(int dfd, const char *pathname,
36933693
struct path *path, unsigned int lookup_flags)
36943694
{
3695-
struct dentry *res = __filename_create(dfd, name, path, lookup_flags);
3695+
struct filename *filename = getname_kernel(pathname);
3696+
struct dentry *res = filename_create(dfd, filename, path, lookup_flags);
36963697

3697-
putname(name);
3698+
putname(filename);
36983699
return res;
36993700
}
3700-
3701-
struct dentry *kern_path_create(int dfd, const char *pathname,
3702-
struct path *path, unsigned int lookup_flags)
3703-
{
3704-
return filename_create(dfd, getname_kernel(pathname),
3705-
path, lookup_flags);
3706-
}
37073701
EXPORT_SYMBOL(kern_path_create);
37083702

37093703
void done_path_create(struct path *path, struct dentry *dentry)
@@ -3718,7 +3712,11 @@ EXPORT_SYMBOL(done_path_create);
37183712
inline struct dentry *user_path_create(int dfd, const char __user *pathname,
37193713
struct path *path, unsigned int lookup_flags)
37203714
{
3721-
return filename_create(dfd, getname(pathname), path, lookup_flags);
3715+
struct filename *filename = getname(pathname);
3716+
struct dentry *res = filename_create(dfd, filename, path, lookup_flags);
3717+
3718+
putname(filename);
3719+
return res;
37223720
}
37233721
EXPORT_SYMBOL(user_path_create);
37243722

@@ -3799,7 +3797,7 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
37993797
if (error)
38003798
goto out1;
38013799
retry:
3802-
dentry = __filename_create(dfd, name, &path, lookup_flags);
3800+
dentry = filename_create(dfd, name, &path, lookup_flags);
38033801
error = PTR_ERR(dentry);
38043802
if (IS_ERR(dentry))
38053803
goto out1;
@@ -3899,7 +3897,7 @@ int do_mkdirat(int dfd, struct filename *name, umode_t mode)
38993897
unsigned int lookup_flags = LOOKUP_DIRECTORY;
39003898

39013899
retry:
3902-
dentry = __filename_create(dfd, name, &path, lookup_flags);
3900+
dentry = filename_create(dfd, name, &path, lookup_flags);
39033901
error = PTR_ERR(dentry);
39043902
if (IS_ERR(dentry))
39053903
goto out_putname;
@@ -4268,7 +4266,7 @@ int do_symlinkat(struct filename *from, int newdfd, struct filename *to)
42684266
goto out_putnames;
42694267
}
42704268
retry:
4271-
dentry = __filename_create(newdfd, to, &path, lookup_flags);
4269+
dentry = filename_create(newdfd, to, &path, lookup_flags);
42724270
error = PTR_ERR(dentry);
42734271
if (IS_ERR(dentry))
42744272
goto out_putnames;
@@ -4432,7 +4430,7 @@ int do_linkat(int olddfd, struct filename *old, int newdfd,
44324430
if (error)
44334431
goto out_putnames;
44344432

4435-
new_dentry = __filename_create(newdfd, new, &new_path,
4433+
new_dentry = filename_create(newdfd, new, &new_path,
44364434
(how & LOOKUP_REVAL));
44374435
error = PTR_ERR(new_dentry);
44384436
if (IS_ERR(new_dentry))

0 commit comments

Comments
 (0)