Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiphi1978
linux
提交
7cbe66b6
L
linux
项目概览
xiphi1978
/
linux
通知
2
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,发现更多精彩内容 >>
提交
7cbe66b6
编写于
8月 05, 2009
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge sock_alloc_fd/sock_attach_fd into a new helper
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
198de4d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
57 deletion
+23
-57
net/socket.c
net/socket.c
+23
-57
未找到文件。
net/socket.c
浏览文件 @
7cbe66b6
...
...
@@ -355,32 +355,30 @@ static const struct dentry_operations sockfs_dentry_operations = {
* but we take care of internal coherence yet.
*/
static
int
sock_alloc_f
d
(
struct
file
**
filep
,
int
flags
)
static
int
sock_alloc_f
ile
(
struct
socket
*
sock
,
struct
file
**
f
,
int
flags
)
{
struct
qstr
name
=
{
.
name
=
""
};
struct
dentry
*
dentry
;
struct
file
*
file
;
int
fd
;
fd
=
get_unused_fd_flags
(
flags
);
if
(
likely
(
fd
>=
0
))
{
struct
file
*
file
=
get_empty_filp
()
;
if
(
unlikely
(
fd
<
0
))
return
fd
;
*
filep
=
file
;
if
(
unlikely
(
!
file
))
{
put_unused_fd
(
fd
);
return
-
ENFILE
;
}
}
else
*
filep
=
NULL
;
return
fd
;
}
file
=
get_empty_filp
();
static
int
sock_attach_fd
(
struct
socket
*
sock
,
struct
file
*
file
,
int
flags
)
{
struct
dentry
*
dentry
;
struct
qstr
name
=
{
.
name
=
""
};
if
(
unlikely
(
!
file
))
{
put_unused_fd
(
fd
);
return
-
ENFILE
;
}
dentry
=
d_alloc
(
sock_mnt
->
mnt_sb
->
s_root
,
&
name
);
if
(
unlikely
(
!
dentry
))
if
(
unlikely
(
!
dentry
))
{
put_filp
(
file
);
put_unused_fd
(
fd
);
return
-
ENOMEM
;
}
dentry
->
d_op
=
&
sockfs_dentry_operations
;
/*
...
...
@@ -399,24 +397,18 @@ static int sock_attach_fd(struct socket *sock, struct file *file, int flags)
file
->
f_pos
=
0
;
file
->
private_data
=
sock
;
return
0
;
*
f
=
file
;
return
fd
;
}
int
sock_map_fd
(
struct
socket
*
sock
,
int
flags
)
{
struct
file
*
newfile
;
int
fd
=
sock_alloc_fd
(
&
newfile
,
flags
);
if
(
likely
(
fd
>=
0
))
{
int
err
=
sock_attach_fd
(
sock
,
newfile
,
flags
);
int
fd
=
sock_alloc_file
(
sock
,
&
newfile
,
flags
);
if
(
unlikely
(
err
<
0
))
{
put_filp
(
newfile
);
put_unused_fd
(
fd
);
return
err
;
}
if
(
likely
(
fd
>=
0
))
fd_install
(
fd
,
newfile
);
}
return
fd
;
}
...
...
@@ -1390,20 +1382,13 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
if
(
err
<
0
)
goto
out_release_both
;
fd1
=
sock_alloc_f
d
(
&
newfile1
,
flags
&
O_CLOEXEC
);
fd1
=
sock_alloc_f
ile
(
sock1
,
&
newfile1
,
flags
);
if
(
unlikely
(
fd1
<
0
))
{
err
=
fd1
;
goto
out_release_both
;
}
err
=
sock_attach_fd
(
sock1
,
newfile1
,
flags
&
O_NONBLOCK
);
if
(
unlikely
(
err
<
0
))
{
put_filp
(
newfile1
);
put_unused_fd
(
fd1
);
goto
out_release_both
;
}
fd2
=
sock_alloc_fd
(
&
newfile2
,
flags
&
O_CLOEXEC
);
fd2
=
sock_alloc_file
(
sock2
,
&
newfile2
,
flags
);
if
(
unlikely
(
fd2
<
0
))
{
err
=
fd2
;
fput
(
newfile1
);
...
...
@@ -1412,16 +1397,6 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
goto
out
;
}
err
=
sock_attach_fd
(
sock2
,
newfile2
,
flags
&
O_NONBLOCK
);
if
(
unlikely
(
err
<
0
))
{
put_filp
(
newfile2
);
put_unused_fd
(
fd2
);
fput
(
newfile1
);
put_unused_fd
(
fd1
);
sock_release
(
sock2
);
goto
out
;
}
audit_fd_pair
(
fd1
,
fd2
);
fd_install
(
fd1
,
newfile1
);
fd_install
(
fd2
,
newfile2
);
...
...
@@ -1548,17 +1523,13 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
*/
__module_get
(
newsock
->
ops
->
owner
);
newfd
=
sock_alloc_f
d
(
&
newfile
,
flags
&
O_CLOEXEC
);
newfd
=
sock_alloc_f
ile
(
newsock
,
&
newfile
,
flags
);
if
(
unlikely
(
newfd
<
0
))
{
err
=
newfd
;
sock_release
(
newsock
);
goto
out_put
;
}
err
=
sock_attach_fd
(
newsock
,
newfile
,
flags
&
O_NONBLOCK
);
if
(
err
<
0
)
goto
out_fd_simple
;
err
=
security_socket_accept
(
sock
,
newsock
);
if
(
err
)
goto
out_fd
;
...
...
@@ -1588,11 +1559,6 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
fput_light
(
sock
->
file
,
fput_needed
);
out:
return
err
;
out_fd_simple:
sock_release
(
newsock
);
put_filp
(
newfile
);
put_unused_fd
(
newfd
);
goto
out_put
;
out_fd:
fput
(
newfile
);
put_unused_fd
(
newfd
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录