Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
483ce1d4
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
483ce1d4
编写于
8月 19, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
take descriptor-related part of close() to file.c
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
0ee8cdfe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
53 deletion
+31
-53
drivers/staging/android/binder.c
drivers/staging/android/binder.c
+2
-32
fs/file.c
fs/file.c
+26
-0
fs/open.c
fs/open.c
+1
-21
include/linux/fdtable.h
include/linux/fdtable.h
+2
-0
未找到文件。
drivers/staging/android/binder.c
浏览文件 @
483ce1d4
...
...
@@ -390,43 +390,17 @@ static void task_fd_install(
__fd_install
(
proc
->
files
,
fd
,
file
);
}
/*
* copied from __put_unused_fd in open.c
*/
static
void
__put_unused_fd
(
struct
files_struct
*
files
,
unsigned
int
fd
)
{
struct
fdtable
*
fdt
=
files_fdtable
(
files
);
__clear_open_fd
(
fd
,
fdt
);
if
(
fd
<
files
->
next_fd
)
files
->
next_fd
=
fd
;
}
/*
* copied from sys_close
*/
static
long
task_close_fd
(
struct
binder_proc
*
proc
,
unsigned
int
fd
)
{
struct
file
*
filp
;
struct
files_struct
*
files
=
proc
->
files
;
struct
fdtable
*
fdt
;
int
retval
;
if
(
files
==
NULL
)
if
(
proc
->
files
==
NULL
)
return
-
ESRCH
;
spin_lock
(
&
files
->
file_lock
);
fdt
=
files_fdtable
(
files
);
if
(
fd
>=
fdt
->
max_fds
)
goto
out_unlock
;
filp
=
fdt
->
fd
[
fd
];
if
(
!
filp
)
goto
out_unlock
;
rcu_assign_pointer
(
fdt
->
fd
[
fd
],
NULL
);
__clear_close_on_exec
(
fd
,
fdt
);
__put_unused_fd
(
files
,
fd
);
spin_unlock
(
&
files
->
file_lock
);
retval
=
filp_close
(
filp
,
files
);
retval
=
__close_fd
(
proc
->
files
,
fd
);
/* can't restart close syscall because file table entry was cleared */
if
(
unlikely
(
retval
==
-
ERESTARTSYS
||
retval
==
-
ERESTARTNOINTR
||
...
...
@@ -435,10 +409,6 @@ static long task_close_fd(struct binder_proc *proc, unsigned int fd)
retval
=
-
EINTR
;
return
retval
;
out_unlock:
spin_unlock
(
&
files
->
file_lock
);
return
-
EBADF
;
}
static
void
binder_set_nice
(
long
nice
)
...
...
fs/file.c
浏览文件 @
483ce1d4
...
...
@@ -626,6 +626,32 @@ void fd_install(unsigned int fd, struct file *file)
EXPORT_SYMBOL
(
fd_install
);
/*
* The same warnings as for __alloc_fd()/__fd_install() apply here...
*/
int
__close_fd
(
struct
files_struct
*
files
,
unsigned
fd
)
{
struct
file
*
file
;
struct
fdtable
*
fdt
;
spin_lock
(
&
files
->
file_lock
);
fdt
=
files_fdtable
(
files
);
if
(
fd
>=
fdt
->
max_fds
)
goto
out_unlock
;
file
=
fdt
->
fd
[
fd
];
if
(
!
file
)
goto
out_unlock
;
rcu_assign_pointer
(
fdt
->
fd
[
fd
],
NULL
);
__clear_close_on_exec
(
fd
,
fdt
);
__put_unused_fd
(
files
,
fd
);
spin_unlock
(
&
files
->
file_lock
);
return
filp_close
(
file
,
files
);
out_unlock:
spin_unlock
(
&
files
->
file_lock
);
return
-
EBADF
;
}
struct
file
*
fget
(
unsigned
int
fd
)
{
struct
file
*
file
;
...
...
fs/open.c
浏览文件 @
483ce1d4
...
...
@@ -994,23 +994,7 @@ EXPORT_SYMBOL(filp_close);
*/
SYSCALL_DEFINE1
(
close
,
unsigned
int
,
fd
)
{
struct
file
*
filp
;
struct
files_struct
*
files
=
current
->
files
;
struct
fdtable
*
fdt
;
int
retval
;
spin_lock
(
&
files
->
file_lock
);
fdt
=
files_fdtable
(
files
);
if
(
fd
>=
fdt
->
max_fds
)
goto
out_unlock
;
filp
=
fdt
->
fd
[
fd
];
if
(
!
filp
)
goto
out_unlock
;
rcu_assign_pointer
(
fdt
->
fd
[
fd
],
NULL
);
__clear_close_on_exec
(
fd
,
fdt
);
__put_unused_fd
(
files
,
fd
);
spin_unlock
(
&
files
->
file_lock
);
retval
=
filp_close
(
filp
,
files
);
int
retval
=
__close_fd
(
current
->
files
,
fd
);
/* can't restart close syscall because file table entry was cleared */
if
(
unlikely
(
retval
==
-
ERESTARTSYS
||
...
...
@@ -1020,10 +1004,6 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
retval
=
-
EINTR
;
return
retval
;
out_unlock:
spin_unlock
(
&
files
->
file_lock
);
return
-
EBADF
;
}
EXPORT_SYMBOL
(
sys_close
);
...
...
include/linux/fdtable.h
浏览文件 @
483ce1d4
...
...
@@ -123,6 +123,8 @@ extern int __alloc_fd(struct files_struct *files,
unsigned
start
,
unsigned
end
,
unsigned
flags
);
extern
void
__fd_install
(
struct
files_struct
*
files
,
unsigned
int
fd
,
struct
file
*
file
);
extern
int
__close_fd
(
struct
files_struct
*
files
,
unsigned
int
fd
);
extern
struct
kmem_cache
*
files_cachep
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录