Commit e24977d4 authored by Al Viro's avatar Al Viro

Reduce path_lookup() abuses

... use kern_path() where possible

[folded a fix from rdd]
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 6b3304b5
......@@ -173,26 +173,26 @@ static const struct file_operations osd_fops = {
.unlocked_ioctl = osd_uld_ioctl,
};
struct osd_dev *osduld_path_lookup(const char *path)
struct osd_dev *osduld_path_lookup(const char *name)
{
struct nameidata nd;
struct path path;
struct inode *inode;
struct cdev *cdev;
struct osd_uld_device *uninitialized_var(oud);
int error;
if (!path || !*path) {
if (!name || !*name) {
OSD_ERR("Mount with !path || !*path\n");
return ERR_PTR(-EINVAL);
}
error = path_lookup(path, LOOKUP_FOLLOW, &nd);
error = kern_path(name, LOOKUP_FOLLOW, &path);
if (error) {
OSD_ERR("path_lookup of %s faild=>%d\n", path, error);
OSD_ERR("path_lookup of %s failed=>%d\n", name, error);
return ERR_PTR(error);
}
inode = nd.path.dentry->d_inode;
inode = path.dentry->d_inode;
error = -EINVAL; /* Not the right device e.g osd_uld_device */
if (!S_ISCHR(inode->i_mode)) {
OSD_DEBUG("!S_ISCHR()\n");
......@@ -202,15 +202,15 @@ struct osd_dev *osduld_path_lookup(const char *path)
cdev = inode->i_cdev;
if (!cdev) {
OSD_ERR("Before mounting an OSD Based filesystem\n");
OSD_ERR(" user-mode must open+close the %s device\n", path);
OSD_ERR(" Example: bash: echo < %s\n", path);
OSD_ERR(" user-mode must open+close the %s device\n", name);
OSD_ERR(" Example: bash: echo < %s\n", name);
goto out;
}
/* The Magic wand. Is it our char-dev */
/* TODO: Support sg devices */
if (cdev->owner != THIS_MODULE) {
OSD_ERR("Error mounting %s - is not an OSD device\n", path);
OSD_ERR("Error mounting %s - is not an OSD device\n", name);
goto out;
}
......@@ -220,7 +220,7 @@ struct osd_dev *osduld_path_lookup(const char *path)
error = 0;
out:
path_put(&nd.path);
path_put(&path);
return error ? ERR_PTR(error) : &oud->od;
}
EXPORT_SYMBOL(osduld_path_lookup);
......
......@@ -1282,21 +1282,21 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags,
static struct super_block *get_gfs2_sb(const char *dev_name)
{
struct super_block *sb;
struct nameidata nd;
struct path path;
int error;
error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
if (error) {
printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n",
dev_name, error);
return NULL;
}
sb = nd.path.dentry->d_inode->i_sb;
sb = path.dentry->d_inode->i_sb;
if (sb && (sb->s_type == &gfs2_fs_type))
atomic_inc(&sb->s_active);
else
sb = NULL;
path_put(&nd.path);
path_put(&path);
return sb;
}
......
......@@ -1720,14 +1720,14 @@ static bool tomoyo_policy_loader_exists(void)
* policies are not loaded yet.
* Thus, let do_execve() call this function everytime.
*/
struct nameidata nd;
struct path path;
if (path_lookup(tomoyo_loader, LOOKUP_FOLLOW, &nd)) {
if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
printk(KERN_INFO "Not activating Mandatory Access Control now "
"since %s doesn't exist.\n", tomoyo_loader);
return false;
}
path_put(&nd.path);
path_put(&path);
return true;
}
......
......@@ -165,11 +165,11 @@ char *tomoyo_realpath_from_path(struct path *path)
*/
char *tomoyo_realpath(const char *pathname)
{
struct nameidata nd;
struct path path;
if (pathname && path_lookup(pathname, LOOKUP_FOLLOW, &nd) == 0) {
char *buf = tomoyo_realpath_from_path(&nd.path);
path_put(&nd.path);
if (pathname && kern_path(pathname, LOOKUP_FOLLOW, &path) == 0) {
char *buf = tomoyo_realpath_from_path(&path);
path_put(&path);
return buf;
}
return NULL;
......@@ -184,11 +184,11 @@ char *tomoyo_realpath(const char *pathname)
*/
char *tomoyo_realpath_nofollow(const char *pathname)
{
struct nameidata nd;
struct path path;
if (pathname && path_lookup(pathname, 0, &nd) == 0) {
char *buf = tomoyo_realpath_from_path(&nd.path);
path_put(&nd.path);
if (pathname && kern_path(pathname, 0, &path) == 0) {
char *buf = tomoyo_realpath_from_path(&path);
path_put(&path);
return buf;
}
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