Skip to content

Commit 390e34b

Browse files
neilbrownbrauner
authored andcommitted
VFS: change lookup_one_common and lookup_noperm_common to take a qstr
These function already take a qstr of course, but they also currently take a name/len was well and fill in the qstr. Now they take a qstr that is already filled in, which is what all the callers have. Signed-off-by: NeilBrown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 06c5674 commit 390e34b

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

fs/namei.c

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,13 +2834,12 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
28342834
}
28352835
EXPORT_SYMBOL(vfs_path_lookup);
28362836

2837-
static int lookup_noperm_common(const char *name, struct dentry *base,
2838-
int len,
2839-
struct qstr *this)
2837+
static int lookup_noperm_common(struct qstr *qname, struct dentry *base)
28402838
{
2841-
this->name = name;
2842-
this->len = len;
2843-
this->hash = full_name_hash(base, name, len);
2839+
const char *name = qname->name;
2840+
u32 len = qname->len;
2841+
2842+
qname->hash = full_name_hash(base, name, len);
28442843
if (!len)
28452844
return -EACCES;
28462845

@@ -2857,18 +2856,18 @@ static int lookup_noperm_common(const char *name, struct dentry *base,
28572856
* to use its own hash..
28582857
*/
28592858
if (base->d_flags & DCACHE_OP_HASH) {
2860-
int err = base->d_op->d_hash(base, this);
2859+
int err = base->d_op->d_hash(base, qname);
28612860
if (err < 0)
28622861
return err;
28632862
}
28642863
return 0;
28652864
}
28662865

28672866
static int lookup_one_common(struct mnt_idmap *idmap,
2868-
const char *name, struct dentry *base, int len,
2869-
struct qstr *this) {
2867+
struct qstr *qname, struct dentry *base)
2868+
{
28702869
int err;
2871-
err = lookup_noperm_common(name, base, len, this);
2870+
err = lookup_noperm_common(qname, base);
28722871
if (err < 0)
28732872
return err;
28742873
return inode_permission(idmap, base->d_inode, MAY_EXEC);
@@ -2890,14 +2889,12 @@ static int lookup_one_common(struct mnt_idmap *idmap,
28902889
*/
28912890
struct dentry *try_lookup_noperm(struct qstr *name, struct dentry *base)
28922891
{
2893-
struct qstr this;
28942892
int err;
28952893

2896-
err = lookup_noperm_common(name->name, base, name->len, &this);
2894+
err = lookup_noperm_common(name, base);
28972895
if (err)
28982896
return ERR_PTR(err);
28992897

2900-
name->hash = this.hash;
29012898
return lookup_dcache(name, base, 0);
29022899
}
29032900
EXPORT_SYMBOL(try_lookup_noperm);
@@ -2915,17 +2912,16 @@ EXPORT_SYMBOL(try_lookup_noperm);
29152912
struct dentry *lookup_noperm(struct qstr *name, struct dentry *base)
29162913
{
29172914
struct dentry *dentry;
2918-
struct qstr this;
29192915
int err;
29202916

29212917
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
29222918

2923-
err = lookup_noperm_common(name->name, base, name->len, &this);
2919+
err = lookup_noperm_common(name, base);
29242920
if (err)
29252921
return ERR_PTR(err);
29262922

2927-
dentry = lookup_dcache(&this, base, 0);
2928-
return dentry ? dentry : __lookup_slow(&this, base, 0);
2923+
dentry = lookup_dcache(name, base, 0);
2924+
return dentry ? dentry : __lookup_slow(name, base, 0);
29292925
}
29302926
EXPORT_SYMBOL(lookup_noperm);
29312927

@@ -2943,17 +2939,16 @@ struct dentry *lookup_one(struct mnt_idmap *idmap, struct qstr *name,
29432939
struct dentry *base)
29442940
{
29452941
struct dentry *dentry;
2946-
struct qstr this;
29472942
int err;
29482943

29492944
WARN_ON_ONCE(!inode_is_locked(base->d_inode));
29502945

2951-
err = lookup_one_common(idmap, name->name, base, name->len, &this);
2946+
err = lookup_one_common(idmap, name, base);
29522947
if (err)
29532948
return ERR_PTR(err);
29542949

2955-
dentry = lookup_dcache(&this, base, 0);
2956-
return dentry ? dentry : __lookup_slow(&this, base, 0);
2950+
dentry = lookup_dcache(name, base, 0);
2951+
return dentry ? dentry : __lookup_slow(name, base, 0);
29572952
}
29582953
EXPORT_SYMBOL(lookup_one);
29592954

@@ -2968,20 +2963,19 @@ EXPORT_SYMBOL(lookup_one);
29682963
* Unlike lookup_one, it should be called without the parent
29692964
* i_rwsem held, and will take the i_rwsem itself if necessary.
29702965
*/
2971-
struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap,
2972-
struct qstr *name, struct dentry *base)
2966+
struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name,
2967+
struct dentry *base)
29732968
{
2974-
struct qstr this;
29752969
int err;
29762970
struct dentry *ret;
29772971

2978-
err = lookup_one_common(idmap, name->name, base, name->len, &this);
2972+
err = lookup_one_common(idmap, name, base);
29792973
if (err)
29802974
return ERR_PTR(err);
29812975

2982-
ret = lookup_dcache(&this, base, 0);
2976+
ret = lookup_dcache(name, base, 0);
29832977
if (!ret)
2984-
ret = lookup_slow(&this, base, 0);
2978+
ret = lookup_slow(name, base, 0);
29852979
return ret;
29862980
}
29872981
EXPORT_SYMBOL(lookup_one_unlocked);

0 commit comments

Comments
 (0)