(root)/
strace-6.5/
tests-m32/
unshare.c
       1  /*
       2   * Check decoding of unshare syscall.
       3   *
       4   * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
       5   * Copyright (c) 2016-2021 The strace developers.
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #include "tests.h"
      12  #include "scno.h"
      13  
      14  #include <stdio.h>
      15  #include <unistd.h>
      16  
      17  int
      18  main(void)
      19  {
      20  	static const kernel_ulong_t bogus_flags =
      21  		(kernel_ulong_t) 0xbadc0ded0000000fULL;
      22  
      23  	static struct {
      24  		kernel_ulong_t val;
      25  		const char *str;
      26  	} unshare_flags[] = {
      27  		{ ARG_STR(0) },
      28  		{ 0xdeadcaf5,
      29  			"CLONE_NEWTIME|CLONE_FS|CLONE_SIGHAND|CLONE_THREAD"
      30  			"|CLONE_SYSVSEM|CLONE_NEWCGROUP|CLONE_NEWUTS"
      31  			"|CLONE_NEWIPC|CLONE_NEWUSER|CLONE_NEWNET|0x80a8c075" },
      32  		{ 0x2000000, "CLONE_NEWCGROUP" },
      33  		{ ARG_STR(0x81f8f07f) " /* CLONE_??? */" },
      34  	};
      35  
      36  	long rc = syscall(__NR_unshare, bogus_flags);
      37  	printf("unshare(%#llx /* CLONE_??? */) = %s\n",
      38  	       (unsigned long long) bogus_flags, sprintrc(rc));
      39  
      40  	for (unsigned int i = 0; i < ARRAY_SIZE(unshare_flags); ++i) {
      41  		rc = syscall(__NR_unshare, unshare_flags[i].val);
      42  		printf("unshare(%s) = %s\n",
      43  		       unshare_flags[i].str, sprintrc(rc));
      44  	}
      45  
      46  	puts("+++ exited with 0 +++");
      47  
      48  	return 0;
      49  }