Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
cdd37e23
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看板
提交
cdd37e23
编写于
4月 26, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
separate namespace-independent parts of filling acct_t
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
ed44724b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
47 deletion
+51
-47
kernel/acct.c
kernel/acct.c
+51
-47
未找到文件。
kernel/acct.c
浏览文件 @
cdd37e23
...
...
@@ -448,42 +448,20 @@ static u32 encode_float(u64 value)
* do_exit() or when switching to a different output file.
*/
/*
* do_acct_process does all actual work. Caller holds the reference to file.
*/
static
void
do_acct_process
(
struct
bsd_acct_struct
*
acct
,
struct
pid_namespace
*
ns
,
struct
file
*
file
)
static
void
fill_ac
(
acct_t
*
ac
)
{
struct
pacct_struct
*
pacct
=
&
current
->
signal
->
pacct
;
acct_t
ac
;
unsigned
long
flim
;
u64
elapsed
,
run_time
;
struct
tty_struct
*
tty
;
const
struct
cred
*
orig_cred
;
/*
* Accounting records are not subject to resource limits.
*/
flim
=
current
->
signal
->
rlim
[
RLIMIT_FSIZE
].
rlim_cur
;
current
->
signal
->
rlim
[
RLIMIT_FSIZE
].
rlim_cur
=
RLIM_INFINITY
;
/* Perform file operations on behalf of whoever enabled accounting */
orig_cred
=
override_creds
(
file
->
f_cred
);
/*
* First check to see if there is enough free_space to continue
* the process accounting system.
*/
if
(
!
check_free_space
(
acct
,
file
))
goto
out
;
/*
* Fill the accounting struct with the needed info as recorded
* by the different kernel functions.
*/
memset
(
&
ac
,
0
,
sizeof
(
acct_t
));
memset
(
ac
,
0
,
sizeof
(
acct_t
));
ac
.
ac_version
=
ACCT_VERSION
|
ACCT_BYTEORDER
;
strlcpy
(
ac
.
ac_comm
,
current
->
comm
,
sizeof
(
ac
.
ac_comm
));
ac
->
ac_version
=
ACCT_VERSION
|
ACCT_BYTEORDER
;
strlcpy
(
ac
->
ac_comm
,
current
->
comm
,
sizeof
(
ac
->
ac_comm
));
/* calculate run_time in nsec*/
run_time
=
ktime_get_ns
();
...
...
@@ -491,27 +469,66 @@ static void do_acct_process(struct bsd_acct_struct *acct,
/* convert nsec -> AHZ */
elapsed
=
nsec_to_AHZ
(
run_time
);
#if ACCT_VERSION==3
ac
.
ac_etime
=
encode_float
(
elapsed
);
ac
->
ac_etime
=
encode_float
(
elapsed
);
#else
ac
.
ac_etime
=
encode_comp_t
(
elapsed
<
(
unsigned
long
)
-
1l
?
ac
->
ac_etime
=
encode_comp_t
(
elapsed
<
(
unsigned
long
)
-
1l
?
(
unsigned
long
)
elapsed
:
(
unsigned
long
)
-
1l
);
#endif
#if ACCT_VERSION==1 || ACCT_VERSION==2
{
/* new enlarged etime field */
comp2_t
etime
=
encode_comp2_t
(
elapsed
);
ac
.
ac_etime_hi
=
etime
>>
16
;
ac
.
ac_etime_lo
=
(
u16
)
etime
;
ac
->
ac_etime_hi
=
etime
>>
16
;
ac
->
ac_etime_lo
=
(
u16
)
etime
;
}
#endif
do_div
(
elapsed
,
AHZ
);
ac
.
ac_btime
=
get_seconds
()
-
elapsed
;
ac
->
ac_btime
=
get_seconds
()
-
elapsed
;
#if ACCT_VERSION==2
ac
->
ac_ahz
=
AHZ
;
#endif
spin_lock_irq
(
&
current
->
sighand
->
siglock
);
tty
=
current
->
signal
->
tty
;
/* Safe as we hold the siglock */
ac
->
ac_tty
=
tty
?
old_encode_dev
(
tty_devnum
(
tty
))
:
0
;
ac
->
ac_utime
=
encode_comp_t
(
jiffies_to_AHZ
(
cputime_to_jiffies
(
pacct
->
ac_utime
)));
ac
->
ac_stime
=
encode_comp_t
(
jiffies_to_AHZ
(
cputime_to_jiffies
(
pacct
->
ac_stime
)));
ac
->
ac_flag
=
pacct
->
ac_flag
;
ac
->
ac_mem
=
encode_comp_t
(
pacct
->
ac_mem
);
ac
->
ac_minflt
=
encode_comp_t
(
pacct
->
ac_minflt
);
ac
->
ac_majflt
=
encode_comp_t
(
pacct
->
ac_majflt
);
ac
->
ac_exitcode
=
pacct
->
ac_exitcode
;
spin_unlock_irq
(
&
current
->
sighand
->
siglock
);
}
/*
* do_acct_process does all actual work. Caller holds the reference to file.
*/
static
void
do_acct_process
(
struct
bsd_acct_struct
*
acct
,
struct
pid_namespace
*
ns
,
struct
file
*
file
)
{
acct_t
ac
;
unsigned
long
flim
;
const
struct
cred
*
orig_cred
;
/*
* Accounting records are not subject to resource limits.
*/
flim
=
current
->
signal
->
rlim
[
RLIMIT_FSIZE
].
rlim_cur
;
current
->
signal
->
rlim
[
RLIMIT_FSIZE
].
rlim_cur
=
RLIM_INFINITY
;
/* Perform file operations on behalf of whoever enabled accounting */
orig_cred
=
override_creds
(
file
->
f_cred
);
/*
* First check to see if there is enough free_space to continue
* the process accounting system.
*/
if
(
!
check_free_space
(
acct
,
file
))
goto
out
;
fill_ac
(
&
ac
);
/* we really need to bite the bullet and change layout */
ac
.
ac_uid
=
from_kuid_munged
(
file
->
f_cred
->
user_ns
,
orig_cred
->
uid
);
ac
.
ac_gid
=
from_kgid_munged
(
file
->
f_cred
->
user_ns
,
orig_cred
->
gid
);
#if ACCT_VERSION==2
ac
.
ac_ahz
=
AHZ
;
#endif
#if ACCT_VERSION==1 || ACCT_VERSION==2
/* backward-compatible 16 bit fields */
ac
.
ac_uid16
=
ac
.
ac_uid
;
...
...
@@ -523,19 +540,6 @@ static void do_acct_process(struct bsd_acct_struct *acct,
ac
.
ac_ppid
=
task_tgid_nr_ns
(
rcu_dereference
(
current
->
real_parent
),
ns
);
rcu_read_unlock
();
#endif
spin_lock_irq
(
&
current
->
sighand
->
siglock
);
tty
=
current
->
signal
->
tty
;
/* Safe as we hold the siglock */
ac
.
ac_tty
=
tty
?
old_encode_dev
(
tty_devnum
(
tty
))
:
0
;
ac
.
ac_utime
=
encode_comp_t
(
jiffies_to_AHZ
(
cputime_to_jiffies
(
pacct
->
ac_utime
)));
ac
.
ac_stime
=
encode_comp_t
(
jiffies_to_AHZ
(
cputime_to_jiffies
(
pacct
->
ac_stime
)));
ac
.
ac_flag
=
pacct
->
ac_flag
;
ac
.
ac_mem
=
encode_comp_t
(
pacct
->
ac_mem
);
ac
.
ac_minflt
=
encode_comp_t
(
pacct
->
ac_minflt
);
ac
.
ac_majflt
=
encode_comp_t
(
pacct
->
ac_majflt
);
ac
.
ac_exitcode
=
pacct
->
ac_exitcode
;
spin_unlock_irq
(
&
current
->
sighand
->
siglock
);
/*
* Get freeze protection. If the fs is frozen, just skip the write
* as we could deadlock the system otherwise.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录