Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
faf02010
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
faf02010
编写于
7月 20, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean unix_bind() up a bit
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
a8104a9f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
43 addition
and
45 deletion
+43
-45
net/unix/af_unix.c
net/unix/af_unix.c
+43
-45
未找到文件。
net/unix/af_unix.c
浏览文件 @
faf02010
...
...
@@ -814,6 +814,34 @@ static struct sock *unix_find_other(struct net *net,
return
NULL
;
}
static
int
unix_mknod
(
const
char
*
sun_path
,
umode_t
mode
,
struct
path
*
res
)
{
struct
dentry
*
dentry
;
struct
path
path
;
int
err
=
0
;
/*
* Get the parent directory, calculate the hash for last
* component.
*/
dentry
=
kern_path_create
(
AT_FDCWD
,
sun_path
,
&
path
,
0
);
err
=
PTR_ERR
(
dentry
);
if
(
IS_ERR
(
dentry
))
return
err
;
/*
* All right, let's create it.
*/
err
=
security_path_mknod
(
&
path
,
dentry
,
mode
,
0
);
if
(
!
err
)
{
err
=
vfs_mknod
(
path
.
dentry
->
d_inode
,
dentry
,
mode
,
0
);
if
(
!
err
)
{
res
->
mnt
=
mntget
(
path
.
mnt
);
res
->
dentry
=
dget
(
dentry
);
}
}
done_path_create
(
&
path
,
dentry
);
return
err
;
}
static
int
unix_bind
(
struct
socket
*
sock
,
struct
sockaddr
*
uaddr
,
int
addr_len
)
{
...
...
@@ -822,8 +850,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
struct
unix_sock
*
u
=
unix_sk
(
sk
);
struct
sockaddr_un
*
sunaddr
=
(
struct
sockaddr_un
*
)
uaddr
;
char
*
sun_path
=
sunaddr
->
sun_path
;
struct
dentry
*
dentry
=
NULL
;
struct
path
path
;
int
err
;
unsigned
int
hash
;
struct
unix_address
*
addr
;
...
...
@@ -860,40 +886,23 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
atomic_set
(
&
addr
->
refcnt
,
1
);
if
(
sun_path
[
0
])
{
umode_t
mode
;
err
=
0
;
/*
* Get the parent directory, calculate the hash for last
* component.
*/
dentry
=
kern_path_create
(
AT_FDCWD
,
sun_path
,
&
path
,
0
);
err
=
PTR_ERR
(
dentry
);
if
(
IS_ERR
(
dentry
))
goto
out_mknod_parent
;
/*
* All right, let's create it.
*/
mode
=
S_IFSOCK
|
struct
path
path
;
umode_t
mode
=
S_IFSOCK
|
(
SOCK_INODE
(
sock
)
->
i_mode
&
~
current_umask
());
err
=
security_path_mknod
(
&
path
,
dentry
,
mode
,
0
);
if
(
err
)
goto
out_mknod_drop_write
;
err
=
vfs_mknod
(
path
.
dentry
->
d_inode
,
dentry
,
mode
,
0
);
out_mknod_drop_write:
if
(
err
)
goto
out_mknod_dput
;
mntget
(
path
.
mnt
);
dget
(
dentry
);
done_path_create
(
&
path
,
dentry
);
path
.
dentry
=
dentry
;
addr
->
hash
=
UNIX_HASH_SIZE
;
err
=
unix_mknod
(
sun_path
,
mode
,
&
path
);
if
(
err
)
{
if
(
err
==
-
EEXIST
)
err
=
-
EADDRINUSE
;
unix_release_addr
(
addr
);
goto
out_up
;
}
addr
->
hash
=
UNIX_HASH_SIZE
;
hash
=
path
.
dentry
->
d_inode
->
i_ino
&
(
UNIX_HASH_SIZE
-
1
);
spin_lock
(
&
unix_table_lock
);
u
->
path
=
path
;
list
=
&
unix_socket_table
[
hash
];
}
else
{
spin_lock
(
&
unix_table_lock
);
if
(
!
sun_path
[
0
])
{
err
=
-
EADDRINUSE
;
if
(
__unix_find_socket_byname
(
net
,
sunaddr
,
addr_len
,
sk
->
sk_type
,
hash
))
{
...
...
@@ -902,9 +911,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
}
list
=
&
unix_socket_table
[
addr
->
hash
];
}
else
{
list
=
&
unix_socket_table
[
dentry
->
d_inode
->
i_ino
&
(
UNIX_HASH_SIZE
-
1
)];
u
->
path
=
path
;
}
err
=
0
;
...
...
@@ -918,14 +924,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
mutex_unlock
(
&
u
->
readlock
);
out:
return
err
;
out_mknod_dput:
done_path_create
(
&
path
,
dentry
);
out_mknod_parent:
if
(
err
==
-
EEXIST
)
err
=
-
EADDRINUSE
;
unix_release_addr
(
addr
);
goto
out_up
;
}
static
void
unix_state_double_lock
(
struct
sock
*
sk1
,
struct
sock
*
sk2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录