[LTP] [PATCH v3 2/3] tst_cgroup: Add safe_cg_open and safe_cg_fchown functions
xuyang2018.jy@fujitsu.com
xuyang2018.jy@fujitsu.com
Fri Aug 26 04:04:51 CEST 2022
Hi Richard
>
> Richard Palethorpe <rpalethorpe@suse.de> writes:
>
>> Hello,
>>
>> Yang Xu <xuyang2018.jy@fujitsu.com> writes:
>>
>>> safe_cg_open is used to open the sub control's file ie cgroup.procs
>>> and returns the opened fd number. The opened fd array is stored in
>>> fds argument.
>>>
>>> safe_cg_fchown is used to use fchownat to change file's uid and gid.
>>>
>>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>>> ---
>>> include/tst_cgroup.h | 44 +++++++++++++++++++++++++++++
>>> lib/tst_cgroup.c | 66 +++++++++++++++++++++++++++-----------------
>>> 2 files changed, 85 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/include/tst_cgroup.h b/include/tst_cgroup.h
>>> index d06847cc6..70c5b3fd4 100644
>>> --- a/include/tst_cgroup.h
>>> +++ b/include/tst_cgroup.h
>>> @@ -89,6 +89,32 @@ enum tst_cg_ver {
>>> TST_CG_V2 = 2,
>>> };
>>>
>>> +/* Controller sub-systems */
>>> +enum cgroup_ctrl_indx {
>>> + CTRL_MEMORY = 1,
>>> + CTRL_CPU,
>>> + CTRL_CPUSET,
>>> + CTRL_IO,
>>> + CTRL_PIDS,
>>> + CTRL_HUGETLB,
>>> + CTRL_CPUACCT,
>>> + CTRL_DEVICES,
>>> + CTRL_FREEZER,
>>> + CTRL_NETCLS,
>>> + CTRL_NETPRIO,
>>> + CTRL_BLKIO,
>>> + CTRL_MISC,
>>> + CTRL_PERFEVENT,
>>> + CTRL_DEBUG
>>> +};
>>> +
>>> +#define CTRLS_MAX CTRL_DEBUG
>>> +
>>> +/* At most we can have one cgroup V1 tree for each controller and one
>>> + * (empty) v2 tree.
>>> + */
>>> +#define ROOTS_MAX (CTRLS_MAX + 1)
>>
>> These need TST_CG_ prepending to them to stop name collisions.
>
> Actually, I think the easiest thing to do is not export these. Instead
> you could leave these alone and export "#define TST_CG_ROOTS_MAX 32".
Yes, I forgot ltp name rules when export it.
Will use TST_CG_ROOTS_MAX in v4 and add your reviewed-by.
Best Regards
Yang Xu
>
> The rest of the patch-set looks great.
>
More information about the ltp
mailing list