anon_inode_getfile(): switch to alloc_file_pseudo()
Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e68375c850
commit
52c91f8b3b
@ -71,8 +71,6 @@ struct file *anon_inode_getfile(const char *name,
|
|||||||
const struct file_operations *fops,
|
const struct file_operations *fops,
|
||||||
void *priv, int flags)
|
void *priv, int flags)
|
||||||
{
|
{
|
||||||
struct qstr this;
|
|
||||||
struct path path;
|
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
||||||
if (IS_ERR(anon_inode_inode))
|
if (IS_ERR(anon_inode_inode))
|
||||||
@ -81,39 +79,24 @@ struct file *anon_inode_getfile(const char *name,
|
|||||||
if (fops->owner && !try_module_get(fops->owner))
|
if (fops->owner && !try_module_get(fops->owner))
|
||||||
return ERR_PTR(-ENOENT);
|
return ERR_PTR(-ENOENT);
|
||||||
|
|
||||||
/*
|
|
||||||
* Link the inode to a directory entry by creating a unique name
|
|
||||||
* using the inode sequence number.
|
|
||||||
*/
|
|
||||||
file = ERR_PTR(-ENOMEM);
|
|
||||||
this.name = name;
|
|
||||||
this.len = strlen(name);
|
|
||||||
this.hash = 0;
|
|
||||||
path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this);
|
|
||||||
if (!path.dentry)
|
|
||||||
goto err_module;
|
|
||||||
|
|
||||||
path.mnt = mntget(anon_inode_mnt);
|
|
||||||
/*
|
/*
|
||||||
* We know the anon_inode inode count is always greater than zero,
|
* We know the anon_inode inode count is always greater than zero,
|
||||||
* so ihold() is safe.
|
* so ihold() is safe.
|
||||||
*/
|
*/
|
||||||
ihold(anon_inode_inode);
|
ihold(anon_inode_inode);
|
||||||
|
file = alloc_file_pseudo(anon_inode_inode, anon_inode_mnt, name,
|
||||||
d_instantiate(path.dentry, anon_inode_inode);
|
flags & (O_ACCMODE | O_NONBLOCK), fops);
|
||||||
|
|
||||||
file = alloc_file(&path, flags & (O_ACCMODE | O_NONBLOCK), fops);
|
|
||||||
if (IS_ERR(file))
|
if (IS_ERR(file))
|
||||||
goto err_dput;
|
goto err;
|
||||||
|
|
||||||
file->f_mapping = anon_inode_inode->i_mapping;
|
file->f_mapping = anon_inode_inode->i_mapping;
|
||||||
|
|
||||||
file->private_data = priv;
|
file->private_data = priv;
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
err_dput:
|
err:
|
||||||
path_put(&path);
|
iput(anon_inode_inode);
|
||||||
err_module:
|
|
||||||
module_put(fops->owner);
|
module_put(fops->owner);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user