mirror of https://gitee.com/openkylin/linux.git
create_pipe_files(): switch the first allocation 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
52c91f8b3b
commit
152b6372c9
32
fs/pipe.c
32
fs/pipe.c
|
@ -744,32 +744,24 @@ static struct inode * get_pipe_inode(void)
|
||||||
|
|
||||||
int create_pipe_files(struct file **res, int flags)
|
int create_pipe_files(struct file **res, int flags)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
struct inode *inode = get_pipe_inode();
|
struct inode *inode = get_pipe_inode();
|
||||||
struct file *f;
|
struct file *f;
|
||||||
struct path path;
|
|
||||||
|
|
||||||
if (!inode)
|
if (!inode)
|
||||||
return -ENFILE;
|
return -ENFILE;
|
||||||
|
|
||||||
err = -ENOMEM;
|
f = alloc_file_pseudo(inode, pipe_mnt, "",
|
||||||
path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &empty_name);
|
O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)),
|
||||||
if (!path.dentry)
|
|
||||||
goto err_inode;
|
|
||||||
path.mnt = mntget(pipe_mnt);
|
|
||||||
|
|
||||||
d_instantiate(path.dentry, inode);
|
|
||||||
|
|
||||||
f = alloc_file(&path, O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)),
|
|
||||||
&pipefifo_fops);
|
&pipefifo_fops);
|
||||||
if (IS_ERR(f)) {
|
if (IS_ERR(f)) {
|
||||||
err = PTR_ERR(f);
|
free_pipe_info(inode->i_pipe);
|
||||||
goto err_dentry;
|
iput(inode);
|
||||||
|
return PTR_ERR(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
f->private_data = inode->i_pipe;
|
f->private_data = inode->i_pipe;
|
||||||
|
|
||||||
res[0] = alloc_file(&path, O_RDONLY | (flags & O_NONBLOCK),
|
res[0] = alloc_file(&f->f_path, O_RDONLY | (flags & O_NONBLOCK),
|
||||||
&pipefifo_fops);
|
&pipefifo_fops);
|
||||||
if (IS_ERR(res[0])) {
|
if (IS_ERR(res[0])) {
|
||||||
put_pipe_info(inode, inode->i_pipe);
|
put_pipe_info(inode, inode->i_pipe);
|
||||||
|
@ -777,20 +769,10 @@ int create_pipe_files(struct file **res, int flags)
|
||||||
return PTR_ERR(res[0]);
|
return PTR_ERR(res[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_get(&path);
|
path_get(&f->f_path);
|
||||||
res[0]->private_data = inode->i_pipe;
|
res[0]->private_data = inode->i_pipe;
|
||||||
res[1] = f;
|
res[1] = f;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_dentry:
|
|
||||||
free_pipe_info(inode->i_pipe);
|
|
||||||
path_put(&path);
|
|
||||||
return err;
|
|
||||||
|
|
||||||
err_inode:
|
|
||||||
free_pipe_info(inode->i_pipe);
|
|
||||||
iput(inode);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __do_pipe_flags(int *fd, struct file **files, int flags)
|
static int __do_pipe_flags(int *fd, struct file **files, int flags)
|
||||||
|
|
Loading…
Reference in New Issue