2020#include "../kselftest.h"
2121#include "clone3_selftests.h"
2222
23- /*
24- * Different sizes of struct clone_args
25- */
26- #ifndef CLONE3_ARGS_SIZE_V0
27- #define CLONE3_ARGS_SIZE_V0 64
28- #endif
29-
3023enum test_mode {
3124 CLONE3_ARGS_NO_TEST ,
3225 CLONE3_ARGS_ALL_0 ,
@@ -38,25 +31,25 @@ enum test_mode {
3831
3932static int call_clone3 (uint64_t flags , size_t size , enum test_mode test_mode )
4033{
41- struct clone_args args = {
34+ struct __clone_args args = {
4235 .flags = flags ,
4336 .exit_signal = SIGCHLD ,
4437 };
4538
4639 struct clone_args_extended {
47- struct clone_args args ;
40+ struct __clone_args args ;
4841 __aligned_u64 excess_space [2 ];
4942 } args_ext ;
5043
5144 pid_t pid = -1 ;
5245 int status ;
5346
5447 memset (& args_ext , 0 , sizeof (args_ext ));
55- if (size > sizeof (struct clone_args ))
48+ if (size > sizeof (struct __clone_args ))
5649 args_ext .excess_space [1 ] = 1 ;
5750
5851 if (size == 0 )
59- size = sizeof (struct clone_args );
52+ size = sizeof (struct __clone_args );
6053
6154 switch (test_mode ) {
6255 case CLONE3_ARGS_ALL_0 :
@@ -77,9 +70,9 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
7770 break ;
7871 }
7972
80- memcpy (& args_ext .args , & args , sizeof (struct clone_args ));
73+ memcpy (& args_ext .args , & args , sizeof (struct __clone_args ));
8174
82- pid = sys_clone3 ((struct clone_args * )& args_ext , size );
75+ pid = sys_clone3 ((struct __clone_args * )& args_ext , size );
8376 if (pid < 0 ) {
8477 ksft_print_msg ("%s - Failed to create new process\n" ,
8578 strerror (errno ));
@@ -144,14 +137,14 @@ int main(int argc, char *argv[])
144137 else
145138 ksft_test_result_skip ("Skipping clone3() with CLONE_NEWPID\n" );
146139
147- /* Do a clone3() with CLONE3_ARGS_SIZE_V0 . */
148- test_clone3 (0 , CLONE3_ARGS_SIZE_V0 , 0 , CLONE3_ARGS_NO_TEST );
140+ /* Do a clone3() with CLONE_ARGS_SIZE_VER0 . */
141+ test_clone3 (0 , CLONE_ARGS_SIZE_VER0 , 0 , CLONE3_ARGS_NO_TEST );
149142
150- /* Do a clone3() with CLONE3_ARGS_SIZE_V0 - 8 */
151- test_clone3 (0 , CLONE3_ARGS_SIZE_V0 - 8 , - EINVAL , CLONE3_ARGS_NO_TEST );
143+ /* Do a clone3() with CLONE_ARGS_SIZE_VER0 - 8 */
144+ test_clone3 (0 , CLONE_ARGS_SIZE_VER0 - 8 , - EINVAL , CLONE3_ARGS_NO_TEST );
152145
153146 /* Do a clone3() with sizeof(struct clone_args) + 8 */
154- test_clone3 (0 , sizeof (struct clone_args ) + 8 , 0 , CLONE3_ARGS_NO_TEST );
147+ test_clone3 (0 , sizeof (struct __clone_args ) + 8 , 0 , CLONE3_ARGS_NO_TEST );
155148
156149 /* Do a clone3() with exit_signal having highest 32 bits non-zero */
157150 test_clone3 (0 , 0 , - EINVAL , CLONE3_ARGS_INVAL_EXIT_SIGNAL_BIG );
@@ -165,31 +158,31 @@ int main(int argc, char *argv[])
165158 /* Do a clone3() with NSIG < exit_signal < CSIG */
166159 test_clone3 (0 , 0 , - EINVAL , CLONE3_ARGS_INVAL_EXIT_SIGNAL_NSIG );
167160
168- test_clone3 (0 , sizeof (struct clone_args ) + 8 , 0 , CLONE3_ARGS_ALL_0 );
161+ test_clone3 (0 , sizeof (struct __clone_args ) + 8 , 0 , CLONE3_ARGS_ALL_0 );
169162
170- test_clone3 (0 , sizeof (struct clone_args ) + 16 , - E2BIG ,
163+ test_clone3 (0 , sizeof (struct __clone_args ) + 16 , - E2BIG ,
171164 CLONE3_ARGS_ALL_0 );
172165
173- test_clone3 (0 , sizeof (struct clone_args ) * 2 , - E2BIG ,
166+ test_clone3 (0 , sizeof (struct __clone_args ) * 2 , - E2BIG ,
174167 CLONE3_ARGS_ALL_0 );
175168
176169 /* Do a clone3() with > page size */
177170 test_clone3 (0 , getpagesize () + 8 , - E2BIG , CLONE3_ARGS_NO_TEST );
178171
179- /* Do a clone3() with CLONE3_ARGS_SIZE_V0 in a new PID NS. */
172+ /* Do a clone3() with CLONE_ARGS_SIZE_VER0 in a new PID NS. */
180173 if (uid == 0 )
181- test_clone3 (CLONE_NEWPID , CLONE3_ARGS_SIZE_V0 , 0 ,
174+ test_clone3 (CLONE_NEWPID , CLONE_ARGS_SIZE_VER0 , 0 ,
182175 CLONE3_ARGS_NO_TEST );
183176 else
184177 ksft_test_result_skip ("Skipping clone3() with CLONE_NEWPID\n" );
185178
186- /* Do a clone3() with CLONE3_ARGS_SIZE_V0 - 8 in a new PID NS */
187- test_clone3 (CLONE_NEWPID , CLONE3_ARGS_SIZE_V0 - 8 , - EINVAL ,
179+ /* Do a clone3() with CLONE_ARGS_SIZE_VER0 - 8 in a new PID NS */
180+ test_clone3 (CLONE_NEWPID , CLONE_ARGS_SIZE_VER0 - 8 , - EINVAL ,
188181 CLONE3_ARGS_NO_TEST );
189182
190183 /* Do a clone3() with sizeof(struct clone_args) + 8 in a new PID NS */
191184 if (uid == 0 )
192- test_clone3 (CLONE_NEWPID , sizeof (struct clone_args ) + 8 , 0 ,
185+ test_clone3 (CLONE_NEWPID , sizeof (struct __clone_args ) + 8 , 0 ,
193186 CLONE3_ARGS_NO_TEST );
194187 else
195188 ksft_test_result_skip ("Skipping clone3() with CLONE_NEWPID\n" );
0 commit comments