Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
0ee8cdfe
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0ee8cdfe
编写于
8月 15, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
take fget() and friends to fs/file.c
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
f869e8a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
106 addition
and
106 deletion
+106
-106
fs/file.c
fs/file.c
+106
-0
fs/file_table.c
fs/file_table.c
+0
-106
未找到文件。
fs/file.c
浏览文件 @
0ee8cdfe
...
...
@@ -625,3 +625,109 @@ void fd_install(unsigned int fd, struct file *file)
}
EXPORT_SYMBOL
(
fd_install
);
struct
file
*
fget
(
unsigned
int
fd
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
/* File object ref couldn't be taken */
if
(
file
->
f_mode
&
FMODE_PATH
||
!
atomic_long_inc_not_zero
(
&
file
->
f_count
))
file
=
NULL
;
}
rcu_read_unlock
();
return
file
;
}
EXPORT_SYMBOL
(
fget
);
struct
file
*
fget_raw
(
unsigned
int
fd
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
/* File object ref couldn't be taken */
if
(
!
atomic_long_inc_not_zero
(
&
file
->
f_count
))
file
=
NULL
;
}
rcu_read_unlock
();
return
file
;
}
EXPORT_SYMBOL
(
fget_raw
);
/*
* Lightweight file lookup - no refcnt increment if fd table isn't shared.
*
* You can use this instead of fget if you satisfy all of the following
* conditions:
* 1) You must call fput_light before exiting the syscall and returning control
* to userspace (i.e. you cannot remember the returned struct file * after
* returning to userspace).
* 2) You must not call filp_close on the returned struct file * in between
* calls to fget_light and fput_light.
* 3) You must not clone the current task in between the calls to fget_light
* and fput_light.
*
* The fput_needed flag returned by fget_light should be passed to the
* corresponding fput_light.
*/
struct
file
*
fget_light
(
unsigned
int
fd
,
int
*
fput_needed
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
*
fput_needed
=
0
;
if
(
atomic_read
(
&
files
->
count
)
==
1
)
{
file
=
fcheck_files
(
files
,
fd
);
if
(
file
&&
(
file
->
f_mode
&
FMODE_PATH
))
file
=
NULL
;
}
else
{
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
if
(
!
(
file
->
f_mode
&
FMODE_PATH
)
&&
atomic_long_inc_not_zero
(
&
file
->
f_count
))
*
fput_needed
=
1
;
else
/* Didn't get the reference, someone's freed */
file
=
NULL
;
}
rcu_read_unlock
();
}
return
file
;
}
struct
file
*
fget_raw_light
(
unsigned
int
fd
,
int
*
fput_needed
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
*
fput_needed
=
0
;
if
(
atomic_read
(
&
files
->
count
)
==
1
)
{
file
=
fcheck_files
(
files
,
fd
);
}
else
{
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
if
(
atomic_long_inc_not_zero
(
&
file
->
f_count
))
*
fput_needed
=
1
;
else
/* Didn't get the reference, someone's freed */
file
=
NULL
;
}
rcu_read_unlock
();
}
return
file
;
}
fs/file_table.c
浏览文件 @
0ee8cdfe
...
...
@@ -339,112 +339,6 @@ void __fput_sync(struct file *file)
EXPORT_SYMBOL
(
fput
);
struct
file
*
fget
(
unsigned
int
fd
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
/* File object ref couldn't be taken */
if
(
file
->
f_mode
&
FMODE_PATH
||
!
atomic_long_inc_not_zero
(
&
file
->
f_count
))
file
=
NULL
;
}
rcu_read_unlock
();
return
file
;
}
EXPORT_SYMBOL
(
fget
);
struct
file
*
fget_raw
(
unsigned
int
fd
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
/* File object ref couldn't be taken */
if
(
!
atomic_long_inc_not_zero
(
&
file
->
f_count
))
file
=
NULL
;
}
rcu_read_unlock
();
return
file
;
}
EXPORT_SYMBOL
(
fget_raw
);
/*
* Lightweight file lookup - no refcnt increment if fd table isn't shared.
*
* You can use this instead of fget if you satisfy all of the following
* conditions:
* 1) You must call fput_light before exiting the syscall and returning control
* to userspace (i.e. you cannot remember the returned struct file * after
* returning to userspace).
* 2) You must not call filp_close on the returned struct file * in between
* calls to fget_light and fput_light.
* 3) You must not clone the current task in between the calls to fget_light
* and fput_light.
*
* The fput_needed flag returned by fget_light should be passed to the
* corresponding fput_light.
*/
struct
file
*
fget_light
(
unsigned
int
fd
,
int
*
fput_needed
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
*
fput_needed
=
0
;
if
(
atomic_read
(
&
files
->
count
)
==
1
)
{
file
=
fcheck_files
(
files
,
fd
);
if
(
file
&&
(
file
->
f_mode
&
FMODE_PATH
))
file
=
NULL
;
}
else
{
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
if
(
!
(
file
->
f_mode
&
FMODE_PATH
)
&&
atomic_long_inc_not_zero
(
&
file
->
f_count
))
*
fput_needed
=
1
;
else
/* Didn't get the reference, someone's freed */
file
=
NULL
;
}
rcu_read_unlock
();
}
return
file
;
}
struct
file
*
fget_raw_light
(
unsigned
int
fd
,
int
*
fput_needed
)
{
struct
file
*
file
;
struct
files_struct
*
files
=
current
->
files
;
*
fput_needed
=
0
;
if
(
atomic_read
(
&
files
->
count
)
==
1
)
{
file
=
fcheck_files
(
files
,
fd
);
}
else
{
rcu_read_lock
();
file
=
fcheck_files
(
files
,
fd
);
if
(
file
)
{
if
(
atomic_long_inc_not_zero
(
&
file
->
f_count
))
*
fput_needed
=
1
;
else
/* Didn't get the reference, someone's freed */
file
=
NULL
;
}
rcu_read_unlock
();
}
return
file
;
}
void
put_filp
(
struct
file
*
file
)
{
if
(
atomic_long_dec_and_test
(
&
file
->
f_count
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录