(root)/
strace-6.5/
tests-m32/
chdir.c
       1  /*
       2   * Check decoding of chdir syscall.
       3   *
       4   * Copyright (c) 2016-2021 The strace developers.
       5   * All rights reserved.
       6   *
       7   * SPDX-License-Identifier: GPL-2.0-or-later
       8   */
       9  
      10  #include "tests.h"
      11  #include "scno.h"
      12  
      13  #include <limits.h>
      14  #include <stdio.h>
      15  #include <string.h>
      16  #include <unistd.h>
      17  
      18  int
      19  main(void)
      20  {
      21  	char *const p = tail_alloc(PATH_MAX);
      22  	memset(p, '/', PATH_MAX);
      23  
      24  	printf("chdir(NULL) = %s\n",
      25  	       sprintrc(syscall(__NR_chdir, NULL)));
      26  
      27  	printf("chdir(\"%.*s\"...) = %s\n",
      28  	       PATH_MAX - 1, p, sprintrc(chdir(p)));
      29  
      30  	p[PATH_MAX - 1] = '\0';
      31  	for (unsigned int i = 0; i < PATH_MAX; ++i)
      32  		printf("chdir(\"%.*s\") = %s\n",
      33  		       PATH_MAX - 1 - i, p + i, sprintrc(chdir(p + i)));
      34  
      35  	puts("+++ exited with 0 +++");
      36  	return 0;
      37  }