Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] assorted path_lookup() -> kern_path() conversions

more nameidata eviction

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 421748ec a63bb996

+34 -37
+7 -7
fs/block_dev.c
··· 1268 1268 * namespace if possible and return it. Return ERR_PTR(error) 1269 1269 * otherwise. 1270 1270 */ 1271 - struct block_device *lookup_bdev(const char *path) 1271 + struct block_device *lookup_bdev(const char *pathname) 1272 1272 { 1273 1273 struct block_device *bdev; 1274 1274 struct inode *inode; 1275 - struct nameidata nd; 1275 + struct path path; 1276 1276 int error; 1277 1277 1278 - if (!path || !*path) 1278 + if (!pathname || !*pathname) 1279 1279 return ERR_PTR(-EINVAL); 1280 1280 1281 - error = path_lookup(path, LOOKUP_FOLLOW, &nd); 1281 + error = kern_path(pathname, LOOKUP_FOLLOW, &path); 1282 1282 if (error) 1283 1283 return ERR_PTR(error); 1284 1284 1285 - inode = nd.path.dentry->d_inode; 1285 + inode = path.dentry->d_inode; 1286 1286 error = -ENOTBLK; 1287 1287 if (!S_ISBLK(inode->i_mode)) 1288 1288 goto fail; 1289 1289 error = -EACCES; 1290 - if (nd.path.mnt->mnt_flags & MNT_NODEV) 1290 + if (path.mnt->mnt_flags & MNT_NODEV) 1291 1291 goto fail; 1292 1292 error = -ENOMEM; 1293 1293 bdev = bd_acquire(inode); 1294 1294 if (!bdev) 1295 1295 goto fail; 1296 1296 out: 1297 - path_put(&nd.path); 1297 + path_put(&path); 1298 1298 return bdev; 1299 1299 fail: 1300 1300 bdev = ERR_PTR(error);
+8 -8
fs/configfs/symlink.c
··· 108 108 } 109 109 110 110 111 - static int get_target(const char *symname, struct nameidata *nd, 111 + static int get_target(const char *symname, struct path *path, 112 112 struct config_item **target) 113 113 { 114 114 int ret; 115 115 116 - ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd); 116 + ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path); 117 117 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); 120 120 if (!*target) { 121 121 ret = -ENOENT; 122 - path_put(&nd->path); 122 + path_put(path); 123 123 } 124 124 } else 125 125 ret = -EPERM; ··· 132 132 int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) 133 133 { 134 134 int ret; 135 - struct nameidata nd; 135 + struct path path; 136 136 struct configfs_dirent *sd; 137 137 struct config_item *parent_item; 138 138 struct config_item *target_item; ··· 159 159 !type->ct_item_ops->allow_link) 160 160 goto out_put; 161 161 162 - ret = get_target(symname, &nd, &target_item); 162 + ret = get_target(symname, &path, &target_item); 163 163 if (ret) 164 164 goto out_put; 165 165 ··· 174 174 } 175 175 176 176 config_item_put(target_item); 177 - path_put(&nd.path); 177 + path_put(&path); 178 178 179 179 out_put: 180 180 config_item_put(parent_item);
+9 -14
fs/ecryptfs/main.c
··· 471 471 */ 472 472 static int ecryptfs_read_super(struct super_block *sb, const char *dev_name) 473 473 { 474 + struct path path; 474 475 int rc; 475 - struct nameidata nd; 476 - struct dentry *lower_root; 477 - struct vfsmount *lower_mnt; 478 476 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); 481 478 if (rc) { 482 479 ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n"); 483 480 goto out; 484 481 } 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); 493 488 if (rc) 494 489 goto out_free; 495 490 rc = 0; 496 491 goto out; 497 492 out_free: 498 - path_put(&nd.path); 493 + path_put(&path); 499 494 out: 500 495 return rc; 501 496 }
+10 -8
net/unix/af_unix.c
··· 711 711 int type, unsigned hash, int *error) 712 712 { 713 713 struct sock *u; 714 - struct nameidata nd; 714 + struct path path; 715 715 int err = 0; 716 716 717 717 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); 719 720 if (err) 720 721 goto fail; 721 - err = vfs_permission(&nd, MAY_WRITE); 722 + inode = path.dentry->d_inode; 723 + err = inode_permission(inode, MAY_WRITE); 722 724 if (err) 723 725 goto put_fail; 724 726 725 727 err = -ECONNREFUSED; 726 - if (!S_ISSOCK(nd.path.dentry->d_inode->i_mode)) 728 + if (!S_ISSOCK(inode->i_mode)) 727 729 goto put_fail; 728 - u = unix_find_socket_byinode(net, nd.path.dentry->d_inode); 730 + u = unix_find_socket_byinode(net, inode); 729 731 if (!u) 730 732 goto put_fail; 731 733 732 734 if (u->sk_type == type) 733 - touch_atime(nd.path.mnt, nd.path.dentry); 735 + touch_atime(path.mnt, path.dentry); 734 736 735 - path_put(&nd.path); 737 + path_put(&path); 736 738 737 739 err=-EPROTOTYPE; 738 740 if (u->sk_type != type) { ··· 755 753 return u; 756 754 757 755 put_fail: 758 - path_put(&nd.path); 756 + path_put(&path); 759 757 fail: 760 758 *error=err; 761 759 return NULL;