forked from luck/tmp_suning_uos_patched
hostfs: pass pathname to init_inode()
We will calculate it in all callers anyway, so there's no need to duplicate that inside. Moreover, that way we lose all failure exits in init_inode(), so it doesn't need to return anything. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
52b209f7b8
commit
5e2df28cc6
|
@ -485,25 +485,16 @@ static const struct address_space_operations hostfs_aops = {
|
||||||
.write_end = hostfs_write_end,
|
.write_end = hostfs_write_end,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int init_inode(struct inode *inode, struct dentry *dentry)
|
static void init_inode(struct inode *inode, char *path)
|
||||||
{
|
{
|
||||||
char *name;
|
int type;
|
||||||
int type, err = -ENOMEM;
|
|
||||||
int maj, min;
|
int maj, min;
|
||||||
dev_t rdev = 0;
|
dev_t rdev = 0;
|
||||||
|
|
||||||
if (dentry) {
|
type = file_type(path, &maj, &min);
|
||||||
name = dentry_name(dentry, 0);
|
/* Reencode maj and min with the kernel encoding.*/
|
||||||
if (name == NULL)
|
rdev = MKDEV(maj, min);
|
||||||
goto out;
|
|
||||||
type = file_type(name, &maj, &min);
|
|
||||||
/* Reencode maj and min with the kernel encoding.*/
|
|
||||||
rdev = MKDEV(maj, min);
|
|
||||||
kfree(name);
|
|
||||||
}
|
|
||||||
else type = OS_TYPE_DIR;
|
|
||||||
|
|
||||||
err = 0;
|
|
||||||
if (type == OS_TYPE_SYMLINK)
|
if (type == OS_TYPE_SYMLINK)
|
||||||
inode->i_op = &page_symlink_inode_operations;
|
inode->i_op = &page_symlink_inode_operations;
|
||||||
else if (type == OS_TYPE_DIR)
|
else if (type == OS_TYPE_DIR)
|
||||||
|
@ -531,8 +522,6 @@ static int init_inode(struct inode *inode, struct dentry *dentry)
|
||||||
init_special_inode(inode, S_IFSOCK, 0);
|
init_special_inode(inode, S_IFSOCK, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
|
int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
|
||||||
|
@ -548,10 +537,6 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = init_inode(inode, dentry);
|
|
||||||
if (error)
|
|
||||||
goto out_put;
|
|
||||||
|
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
name = dentry_name(dentry, 0);
|
name = dentry_name(dentry, 0);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
@ -561,9 +546,12 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
|
||||||
mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
|
mode & S_IRUSR, mode & S_IWUSR, mode & S_IXUSR,
|
||||||
mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
|
mode & S_IRGRP, mode & S_IWGRP, mode & S_IXGRP,
|
||||||
mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
|
mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
error = fd;
|
error = fd;
|
||||||
else error = read_name(inode, name);
|
} else {
|
||||||
|
error = read_name(inode, name);
|
||||||
|
init_inode(inode, name);
|
||||||
|
}
|
||||||
|
|
||||||
kfree(name);
|
kfree(name);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -593,16 +581,14 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = init_inode(inode, dentry);
|
|
||||||
if (err)
|
|
||||||
goto out_put;
|
|
||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
name = dentry_name(dentry, 0);
|
name = dentry_name(dentry, 0);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
goto out_put;
|
goto out_put;
|
||||||
|
|
||||||
err = read_name(inode, name);
|
err = read_name(inode, name);
|
||||||
|
init_inode(inode, name);
|
||||||
|
|
||||||
kfree(name);
|
kfree(name);
|
||||||
if (err == -ENOENT) {
|
if (err == -ENOENT) {
|
||||||
iput(inode);
|
iput(inode);
|
||||||
|
@ -717,10 +703,6 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = init_inode(inode, dentry);
|
|
||||||
if (err)
|
|
||||||
goto out_put;
|
|
||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
name = dentry_name(dentry, 0);
|
name = dentry_name(dentry, 0);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
@ -732,6 +714,9 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
err = read_name(inode, name);
|
err = read_name(inode, name);
|
||||||
|
init_inode(inode, name);
|
||||||
|
if (err)
|
||||||
|
goto out_put;
|
||||||
kfree(name);
|
kfree(name);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_put;
|
goto out_put;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user