selftests/cgroup: Fix build on older distros
PATCH 1/1 selftests/cgroup: Fix build on older distros
On older distros struct clone_args does not have a cgroup member, leading to build errors:
cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'struct clone_args' has no member named 'cgroup'
But the selftests already have a locally defined version of the structure which is up to date, called __clone_args.
So use __clone_args which fixes the error.
--- tools/testing/selftests/cgroup/cgroup_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cgroup/cgroup_util.c +1 -1
@@ -337,7 +337,7 @@ pid_t clone_into_cgroup(int cgroup_fd)#ifdef CLONE_ARGS_SIZE_VER2 pid_t pid; -struct clone_args args = { +struct __clone_args args = { .flags =CLONE_INTO_CGROUP , .exit_signal =SIGCHLD , .cgroup = cgroup_fd,
base-commit: cf7cd542d1b538f6e9e83490bc090dd773f4266d
Signature · 1 line
2.25.1
Quoted 7 lines · Michael Ellerman
On older distros struct
clone_argsdoes not have a cgroup member, leading to build errors:
Quoted 8 lines
cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'structclone_args' has no member named 'cgroup'But the selftests already have a locally defined version of the structure which is up to date, called
__clone_args.So use
__clone_argswhich fixes the error.
Argument passed to sys_clone3() will also require a similar change.
- pid = sys_clone3(&args, sizeof(struct clone_args));
+ pid = sys_clone3(&args, sizeof(struct __clone_args));
Without this compilation still fails(at least for me) due to following error
cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete type 'struct clone_args'
pid = sys_clone3(&args, sizeof(struct clone_args));
Quoted 23 lines
Signed-off-by Michael Ellerman <[email protected]>---
tools/testing/selftests/cgroup/cgroup_util.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/cgroup/cgroup_util.c +1
-1@@ -337,7 +337,7 @@ pid_t clone_into_cgroup(int cgroup_fd)#ifdef CLONE_ARGS_SIZE_VER2 pid_t pid; -struct clone_args args = { +struct __clone_args args = { .flags =CLONE_INTO_CGROUP , .exit_signal =SIGCHLD , .cgroup = cgroup_fd,base-commit:
cf7cd542d1b538f6e9e83490bc090dd773f4266dSignature · 1 line
2.25.1
Christian Brauner
Acked-byQuoted 21 lines · Sachin Sant
Quoted 7 lines · Michael Ellerman
On older distros struct
clone_argsdoes not have a cgroup member, leading to build errors:Quoted 8 lines
cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:343:4: error: 'structclone_args' has no member named 'cgroup'But the selftests already have a locally defined version of the structure which is up to date, called
__clone_args.So use
__clone_argswhich fixes the error.Argument passed to
sys_clone3()will also require a similar change.(quoted diff) +1
-1- pid = sys_clone3(&args, sizeof(struct clone_args)); + pid = sys_clone3(&args, sizeof(struct __clone_args));
Quoted 8 lines
Without this compilation still fails(at least for me) due to following error
cgroup_util.c: In function 'clone_into_cgroup':
cgroup_util.c:346:33: error: invalid application of 'sizeof' to incomplete type 'structclone_args'
pid =sys_clone3(&args, sizeof(struct clone_args));Quoted 2 lines
Signed-off-by Michael Ellerman <[email protected]>---
Thanks Michael for taking care fo this. Much appreciated. I think with the fix that Sachin pointed out this should work out fine!
Once that's fixed up:
Thanks!
Christian