Skip to content

Commit 421748e

Browse files
author
Al Viro
committed
[PATCH] assorted path_lookup() -> kern_path() conversions
more nameidata eviction Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent a63bb99 commit 421748e

4 files changed

Lines changed: 34 additions & 37 deletions

File tree

‎fs/block_dev.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,33 +1268,33 @@ EXPORT_SYMBOL(ioctl_by_bdev);
12681268
* namespace if possible and return it. Return ERR_PTR(error)
12691269
* otherwise.
12701270
*/
1271-
struct block_device *lookup_bdev(const char *path)
1271+
struct block_device *lookup_bdev(const char *pathname)
12721272
{
12731273
struct block_device *bdev;
12741274
struct inode *inode;
1275-
struct nameidata nd;
1275+
struct path path;
12761276
int error;
12771277

1278-
if (!path || !*path)
1278+
if (!pathname || !*pathname)
12791279
return ERR_PTR(-EINVAL);
12801280

1281-
error = path_lookup(path, LOOKUP_FOLLOW, &nd);
1281+
error = kern_path(pathname, LOOKUP_FOLLOW, &path);
12821282
if (error)
12831283
return ERR_PTR(error);
12841284

1285-
inode = nd.path.dentry->d_inode;
1285+
inode = path.dentry->d_inode;
12861286
error = -ENOTBLK;
12871287
if (!S_ISBLK(inode->i_mode))
12881288
goto fail;
12891289
error = -EACCES;
1290-
if (nd.path.mnt->mnt_flags & MNT_NODEV)
1290+
if (path.mnt->mnt_flags & MNT_NODEV)
12911291
goto fail;
12921292
error = -ENOMEM;
12931293
bdev = bd_acquire(inode);
12941294
if (!bdev)
12951295
goto fail;
12961296
out:
1297-
path_put(&nd.path);
1297+
path_put(&path);
12981298
return bdev;
12991299
fail:
13001300
bdev = ERR_PTR(error);

‎fs/configfs/symlink.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ static int create_link(struct config_item *parent_item,
108108
}
109109

110110

111-
static int get_target(const char *symname, struct nameidata *nd,
111+
static int get_target(const char *symname, struct path *path,
112112
struct config_item **target)
113113
{
114114
int ret;
115115

116-
ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd);
116+
ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path);
117117
if (!ret) {
118-
if (nd->path.dentry->d_sb == configfs_sb) {
119-
*target = configfs_get_config_item(nd->path.dentry);
118+
if (path->dentry->d_sb == configfs_sb) {
119+
*target = configfs_get_config_item(path->dentry);
120120
if (!*target) {
121121
ret = -ENOENT;
122-
path_put(&nd->path);
122+
path_put(path);
123123
}
124124
} else
125125
ret = -EPERM;
@@ -132,7 +132,7 @@ static int get_target(const char *symname, struct nameidata *nd,
132132
int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
133133
{
134134
int ret;
135-
struct nameidata nd;
135+
struct path path;
136136
struct configfs_dirent *sd;
137137
struct config_item *parent_item;
138138
struct config_item *target_item;
@@ -159,7 +159,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
159159
!type->ct_item_ops->allow_link)
160160
goto out_put;
161161

162-
ret = get_target(symname, &nd, &target_item);
162+
ret = get_target(symname, &path, &target_item);
163163
if (ret)
164164
goto out_put;
165165

@@ -174,7 +174,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
174174
}
175175

176176
config_item_put(target_item);
177-
path_put(&nd.path);
177+
path_put(&path);
178178

179179
out_put:
180180
config_item_put(parent_item);

‎fs/ecryptfs/main.c‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -471,31 +471,26 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
471471
*/
472472
static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
473473
{
474+
struct path path;
474475
int rc;
475-
struct nameidata nd;
476-
struct dentry *lower_root;
477-
struct vfsmount *lower_mnt;
478476

479-
memset(&nd, 0, sizeof(struct nameidata));
480-
rc = path_lookup(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd);
477+
rc = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
481478
if (rc) {
482479
ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n");
483480
goto out;
484481
}
485-
lower_root = nd.path.dentry;
486-
lower_mnt = nd.path.mnt;
487-
ecryptfs_set_superblock_lower(sb, lower_root->d_sb);
488-
sb->s_maxbytes = lower_root->d_sb->s_maxbytes;
489-
sb->s_blocksize = lower_root->d_sb->s_blocksize;
490-
ecryptfs_set_dentry_lower(sb->s_root, lower_root);
491-
ecryptfs_set_dentry_lower_mnt(sb->s_root, lower_mnt);
492-
rc = ecryptfs_interpose(lower_root, sb->s_root, sb, 0);
482+
ecryptfs_set_superblock_lower(sb, path.dentry->d_sb);
483+
sb->s_maxbytes = path.dentry->d_sb->s_maxbytes;
484+
sb->s_blocksize = path.dentry->d_sb->s_blocksize;
485+
ecryptfs_set_dentry_lower(sb->s_root, path.dentry);
486+
ecryptfs_set_dentry_lower_mnt(sb->s_root, path.mnt);
487+
rc = ecryptfs_interpose(path.dentry, sb->s_root, sb, 0);
493488
if (rc)
494489
goto out_free;
495490
rc = 0;
496491
goto out;
497492
out_free:
498-
path_put(&nd.path);
493+
path_put(&path);
499494
out:
500495
return rc;
501496
}

‎net/unix/af_unix.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,28 +711,30 @@ static struct sock *unix_find_other(struct net *net,
711711
int type, unsigned hash, int *error)
712712
{
713713
struct sock *u;
714-
struct nameidata nd;
714+
struct path path;
715715
int err = 0;
716716

717717
if (sunname->sun_path[0]) {
718-
err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
718+
struct inode *inode;
719+
err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
719720
if (err)
720721
goto fail;
721-
err = vfs_permission(&nd, MAY_WRITE);
722+
inode = path.dentry->d_inode;
723+
err = inode_permission(inode, MAY_WRITE);
722724
if (err)
723725
goto put_fail;
724726

725727
err = -ECONNREFUSED;
726-
if (!S_ISSOCK(nd.path.dentry->d_inode->i_mode))
728+
if (!S_ISSOCK(inode->i_mode))
727729
goto put_fail;
728-
u = unix_find_socket_byinode(net, nd.path.dentry->d_inode);
730+
u = unix_find_socket_byinode(net, inode);
729731
if (!u)
730732
goto put_fail;
731733

732734
if (u->sk_type == type)
733-
touch_atime(nd.path.mnt, nd.path.dentry);
735+
touch_atime(path.mnt, path.dentry);
734736

735-
path_put(&nd.path);
737+
path_put(&path);
736738

737739
err=-EPROTOTYPE;
738740
if (u->sk_type != type) {
@@ -753,7 +755,7 @@ static struct sock *unix_find_other(struct net *net,
753755
return u;
754756

755757
put_fail:
756-
path_put(&nd.path);
758+
path_put(&path);
757759
fail:
758760
*error=err;
759761
return NULL;

0 commit comments

Comments
 (0)