Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
28407630
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
28407630
编写于
8月 17, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
take descriptor handling from sock_alloc_file() to callers
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
5905db5c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
22 deletion
+40
-22
net/socket.c
net/socket.c
+40
-22
未找到文件。
net/socket.c
浏览文件 @
28407630
...
...
@@ -346,22 +346,15 @@ static struct file_system_type sock_fs_type = {
* but we take care of internal coherence yet.
*/
static
int
sock_alloc_file
(
struct
socket
*
sock
,
struct
file
**
f
,
int
flags
)
static
struct
file
*
sock_alloc_file
(
struct
socket
*
sock
,
int
flags
)
{
struct
qstr
name
=
{
.
name
=
""
};
struct
path
path
;
struct
file
*
file
;
int
fd
;
fd
=
get_unused_fd_flags
(
flags
);
if
(
unlikely
(
fd
<
0
))
return
fd
;
path
.
dentry
=
d_alloc_pseudo
(
sock_mnt
->
mnt_sb
,
&
name
);
if
(
unlikely
(
!
path
.
dentry
))
{
put_unused_fd
(
fd
);
return
-
ENOMEM
;
}
if
(
unlikely
(
!
path
.
dentry
))
return
ERR_PTR
(
-
ENOMEM
);
path
.
mnt
=
mntget
(
sock_mnt
);
d_instantiate
(
path
.
dentry
,
SOCK_INODE
(
sock
));
...
...
@@ -373,28 +366,31 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
/* drop dentry, keep inode */
ihold
(
path
.
dentry
->
d_inode
);
path_put
(
&
path
);
put_unused_fd
(
fd
);
return
-
ENFILE
;
return
ERR_PTR
(
-
ENFILE
);
}
sock
->
file
=
file
;
file
->
f_flags
=
O_RDWR
|
(
flags
&
O_NONBLOCK
);
file
->
f_pos
=
0
;
file
->
private_data
=
sock
;
*
f
=
file
;
return
fd
;
return
file
;
}
int
sock_map_fd
(
struct
socket
*
sock
,
int
flags
)
{
struct
file
*
newfile
;
int
fd
=
sock_alloc_file
(
sock
,
&
newfile
,
flags
);
int
fd
=
get_unused_fd_flags
(
flags
);
if
(
unlikely
(
fd
<
0
))
return
fd
;
if
(
likely
(
fd
>=
0
))
newfile
=
sock_alloc_file
(
sock
,
flags
);
if
(
likely
(
!
IS_ERR
(
newfile
)))
{
fd_install
(
fd
,
newfile
);
return
fd
;
}
return
fd
;
put_unused_fd
(
fd
);
return
PTR_ERR
(
newfile
);
}
EXPORT_SYMBOL
(
sock_map_fd
);
...
...
@@ -1394,17 +1390,32 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
if
(
err
<
0
)
goto
out_release_both
;
fd1
=
sock_alloc_file
(
sock1
,
&
newfile1
,
flags
);
fd1
=
get_unused_fd_flags
(
flags
);
if
(
unlikely
(
fd1
<
0
))
{
err
=
fd1
;
goto
out_release_both
;
}
fd2
=
sock_alloc_file
(
sock2
,
&
newfile2
,
flags
);
fd2
=
get_unused_fd_flags
(
flags
);
if
(
unlikely
(
fd2
<
0
))
{
err
=
fd2
;
put_unused_fd
(
fd1
);
goto
out_release_both
;
}
newfile1
=
sock_alloc_file
(
sock1
,
flags
);
if
(
unlikely
(
IS_ERR
(
newfile1
)))
{
err
=
PTR_ERR
(
newfile1
);
put_unused_fd
(
fd1
);
put_unused_fd
(
fd2
);
goto
out_release_both
;
}
newfile2
=
sock_alloc_file
(
sock2
,
flags
);
if
(
IS_ERR
(
newfile2
))
{
err
=
PTR_ERR
(
newfile2
);
fput
(
newfile1
);
put_unused_fd
(
fd1
);
put_unused_fd
(
fd2
);
sock_release
(
sock2
);
goto
out
;
}
...
...
@@ -1536,12 +1547,19 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
*/
__module_get
(
newsock
->
ops
->
owner
);
newfd
=
sock_alloc_file
(
newsock
,
&
newfile
,
flags
);
newfd
=
get_unused_fd_flags
(
flags
);
if
(
unlikely
(
newfd
<
0
))
{
err
=
newfd
;
sock_release
(
newsock
);
goto
out_put
;
}
newfile
=
sock_alloc_file
(
newsock
,
flags
);
if
(
unlikely
(
IS_ERR
(
newfile
)))
{
err
=
PTR_ERR
(
newfile
);
put_unused_fd
(
newfd
);
sock_release
(
newsock
);
goto
out_put
;
}
err
=
security_socket_accept
(
sock
,
newsock
);
if
(
err
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录