Commit 421748ec authored by Al Viro's avatar Al Viro

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

more nameidata eviction
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a63bb996
...@@ -1268,33 +1268,33 @@ EXPORT_SYMBOL(ioctl_by_bdev); ...@@ -1268,33 +1268,33 @@ EXPORT_SYMBOL(ioctl_by_bdev);
* namespace if possible and return it. Return ERR_PTR(error) * namespace if possible and return it. Return ERR_PTR(error)
* otherwise. * otherwise.
*/ */
struct block_device *lookup_bdev(const char *path) struct block_device *lookup_bdev(const char *pathname)
{ {
struct block_device *bdev; struct block_device *bdev;
struct inode *inode; struct inode *inode;
struct nameidata nd; struct path path;
int error; int error;
if (!path || !*path) if (!pathname || !*pathname)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
error = path_lookup(path, LOOKUP_FOLLOW, &nd); error = kern_path(pathname, LOOKUP_FOLLOW, &path);
if (error) if (error)
return ERR_PTR(error); return ERR_PTR(error);
inode = nd.path.dentry->d_inode; inode = path.dentry->d_inode;
error = -ENOTBLK; error = -ENOTBLK;
if (!S_ISBLK(inode->i_mode)) if (!S_ISBLK(inode->i_mode))
goto fail; goto fail;
error = -EACCES; error = -EACCES;
if (nd.path.mnt->mnt_flags & MNT_NODEV) if (path.mnt->mnt_flags & MNT_NODEV)
goto fail; goto fail;
error = -ENOMEM; error = -ENOMEM;
bdev = bd_acquire(inode); bdev = bd_acquire(inode);
if (!bdev) if (!bdev)
goto fail; goto fail;
out: out:
path_put(&nd.path); path_put(&path);
return bdev; return bdev;
fail: fail:
bdev = ERR_PTR(error); bdev = ERR_PTR(error);
......
...@@ -108,18 +108,18 @@ out: ...@@ -108,18 +108,18 @@ out:
} }
static int get_target(const char *symname, struct nameidata *nd, static int get_target(const char *symname, struct path *path,
struct config_item **target) struct config_item **target)
{ {
int ret; int ret;
ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd); ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path);
if (!ret) { if (!ret) {
if (nd->path.dentry->d_sb == configfs_sb) { if (path->dentry->d_sb == configfs_sb) {
*target = configfs_get_config_item(nd->path.dentry); *target = configfs_get_config_item(path->dentry);
if (!*target) { if (!*target) {
ret = -ENOENT; ret = -ENOENT;
path_put(&nd->path); path_put(path);
} }
} else } else
ret = -EPERM; ret = -EPERM;
...@@ -132,7 +132,7 @@ static int get_target(const char *symname, struct nameidata *nd, ...@@ -132,7 +132,7 @@ static int get_target(const char *symname, struct nameidata *nd,
int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
{ {
int ret; int ret;
struct nameidata nd; struct path path;
struct configfs_dirent *sd; struct configfs_dirent *sd;
struct config_item *parent_item; struct config_item *parent_item;
struct config_item *target_item; struct config_item *target_item;
...@@ -159,7 +159,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna ...@@ -159,7 +159,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
!type->ct_item_ops->allow_link) !type->ct_item_ops->allow_link)
goto out_put; goto out_put;
ret = get_target(symname, &nd, &target_item); ret = get_target(symname, &path, &target_item);
if (ret) if (ret)
goto out_put; goto out_put;
...@@ -174,7 +174,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna ...@@ -174,7 +174,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
} }
config_item_put(target_item); config_item_put(target_item);
path_put(&nd.path); path_put(&path);
out_put: out_put:
config_item_put(parent_item); config_item_put(parent_item);
......
...@@ -471,31 +471,26 @@ out: ...@@ -471,31 +471,26 @@ out:
*/ */
static int ecryptfs_read_super(struct super_block *sb, const char *dev_name) static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
{ {
struct path path;
int rc; int rc;
struct nameidata nd;
struct dentry *lower_root;
struct vfsmount *lower_mnt;
memset(&nd, 0, sizeof(struct nameidata)); rc = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
rc = path_lookup(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd);
if (rc) { if (rc) {
ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n"); ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n");
goto out; goto out;
} }
lower_root = nd.path.dentry; ecryptfs_set_superblock_lower(sb, path.dentry->d_sb);
lower_mnt = nd.path.mnt; sb->s_maxbytes = path.dentry->d_sb->s_maxbytes;
ecryptfs_set_superblock_lower(sb, lower_root->d_sb); sb->s_blocksize = path.dentry->d_sb->s_blocksize;
sb->s_maxbytes = lower_root->d_sb->s_maxbytes; ecryptfs_set_dentry_lower(sb->s_root, path.dentry);
sb->s_blocksize = lower_root->d_sb->s_blocksize; ecryptfs_set_dentry_lower_mnt(sb->s_root, path.mnt);
ecryptfs_set_dentry_lower(sb->s_root, lower_root); rc = ecryptfs_interpose(path.dentry, sb->s_root, sb, 0);
ecryptfs_set_dentry_lower_mnt(sb->s_root, lower_mnt);
rc = ecryptfs_interpose(lower_root, sb->s_root, sb, 0);
if (rc) if (rc)
goto out_free; goto out_free;
rc = 0; rc = 0;
goto out; goto out;
out_free: out_free:
path_put(&nd.path); path_put(&path);
out: out:
return rc; return rc;
} }
......
...@@ -711,28 +711,30 @@ static struct sock *unix_find_other(struct net *net, ...@@ -711,28 +711,30 @@ static struct sock *unix_find_other(struct net *net,
int type, unsigned hash, int *error) int type, unsigned hash, int *error)
{ {
struct sock *u; struct sock *u;
struct nameidata nd; struct path path;
int err = 0; int err = 0;
if (sunname->sun_path[0]) { if (sunname->sun_path[0]) {
err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd); struct inode *inode;
err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
if (err) if (err)
goto fail; goto fail;
err = vfs_permission(&nd, MAY_WRITE); inode = path.dentry->d_inode;
err = inode_permission(inode, MAY_WRITE);
if (err) if (err)
goto put_fail; goto put_fail;
err = -ECONNREFUSED; err = -ECONNREFUSED;
if (!S_ISSOCK(nd.path.dentry->d_inode->i_mode)) if (!S_ISSOCK(inode->i_mode))
goto put_fail; goto put_fail;
u = unix_find_socket_byinode(net, nd.path.dentry->d_inode); u = unix_find_socket_byinode(net, inode);
if (!u) if (!u)
goto put_fail; goto put_fail;
if (u->sk_type == type) if (u->sk_type == type)
touch_atime(nd.path.mnt, nd.path.dentry); touch_atime(path.mnt, path.dentry);
path_put(&nd.path); path_put(&path);
err=-EPROTOTYPE; err=-EPROTOTYPE;
if (u->sk_type != type) { if (u->sk_type != type) {
...@@ -753,7 +755,7 @@ static struct sock *unix_find_other(struct net *net, ...@@ -753,7 +755,7 @@ static struct sock *unix_find_other(struct net *net,
return u; return u;
put_fail: put_fail:
path_put(&nd.path); path_put(&path);
fail: fail:
*error=err; *error=err;
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment