提交 cc3808f8 编写于 作者: A Al Viro

switch sock_alloc_file() to alloc_file()

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 6b18662e
...@@ -366,16 +366,8 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) ...@@ -366,16 +366,8 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
if (unlikely(fd < 0)) if (unlikely(fd < 0))
return fd; return fd;
file = get_empty_filp();
if (unlikely(!file)) {
put_unused_fd(fd);
return -ENFILE;
}
dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
if (unlikely(!dentry)) { if (unlikely(!dentry)) {
put_filp(file);
put_unused_fd(fd); put_unused_fd(fd);
return -ENOMEM; return -ENOMEM;
} }
...@@ -388,11 +380,19 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) ...@@ -388,11 +380,19 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
*/ */
dentry->d_flags &= ~DCACHE_UNHASHED; dentry->d_flags &= ~DCACHE_UNHASHED;
d_instantiate(dentry, SOCK_INODE(sock)); d_instantiate(dentry, SOCK_INODE(sock));
SOCK_INODE(sock)->i_fop = &socket_file_ops;
sock->file = file; file = alloc_file(sock_mnt, dentry, FMODE_READ | FMODE_WRITE,
init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE,
&socket_file_ops); &socket_file_ops);
SOCK_INODE(sock)->i_fop = &socket_file_ops; if (unlikely(!file)) {
/* drop dentry, keep inode */
atomic_inc(&path.dentry->d_inode->i_count);
dput(dentry);
put_unused_fd(fd);
return -ENFILE;
}
sock->file = file;
file->f_flags = O_RDWR | (flags & O_NONBLOCK); file->f_flags = O_RDWR | (flags & O_NONBLOCK);
file->f_pos = 0; file->f_pos = 0;
file->private_data = sock; file->private_data = sock;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册