Dmitry V. Levin
f2bb704a92
Do not include <sys/param.h> unnecessarily as it includes <signal.h>. * pathtrace.c: Include <limits.h> instead of <sys/param.h>. * strace.c: Likewise. * syscall.c: Likewise. * util.c: Likewise. * tests/getcwd.c: Likewise. * tests/group_req.c: Likewise. * tests/inode_of_sockfd.c: Likewise. * tests/ip_mreq.c: Likewise. * tests/printpath-umovestr.c: Likewise. * tests/qual_fault.c: Likewise. * tests/test_printpath.c: Likewise. * tests/umovestr3.c: Likewise. * tests/net-y-unix.c: Do not include <sys/param.h>. * tests/net-yy-unix.c: Likewise.
47 lines
917 B
C
47 lines
917 B
C
#include "tests.h"
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
#ifdef __NR_getcwd
|
|
|
|
# include <limits.h>
|
|
# include <stdio.h>
|
|
# include <unistd.h>
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
long res;
|
|
char cur_dir[PATH_MAX + 1];
|
|
static const size_t bogus_size = (size_t) 0xbadc0deddeadfaceULL;
|
|
|
|
res = syscall(__NR_getcwd, cur_dir, sizeof(cur_dir));
|
|
|
|
if (res <= 0)
|
|
perror_msg_and_fail("getcwd");
|
|
|
|
printf("getcwd(");
|
|
print_quoted_string(cur_dir);
|
|
printf(", %zu) = %ld\n", sizeof(cur_dir), res);
|
|
|
|
res = syscall(__NR_getcwd, cur_dir, 0);
|
|
printf("getcwd(%p, 0) = %s\n", cur_dir, sprintrc(res));
|
|
|
|
res = syscall(__NR_getcwd, NULL, bogus_size);
|
|
printf("getcwd(NULL, %zu) = %s\n", bogus_size, sprintrc(res));
|
|
|
|
res = syscall(__NR_getcwd, (void *) -1L, sizeof(cur_dir));
|
|
printf("getcwd(%p, %zu) = %s\n",
|
|
(void *) -1L, sizeof(cur_dir), sprintrc(res));
|
|
|
|
puts("+++ exited with 0 +++");
|
|
|
|
return 0;
|
|
}
|
|
|
|
#else
|
|
|
|
SKIP_MAIN_UNDEFINED("__NR_getcwd");
|
|
|
|
#endif
|