strace/tests/chmod.c
Dmitry V. Levin d6c71dd061 Fix preprocessor indentation
Indent the C preprocessor directives to reflect their nesting
using the following script:

$ cppi -l $(git grep -El '^[[:space:]]*#[[:space:]]*(if|ifdef|ifndef|elif|else|endif|define|pragma)[[:space:]]' |grep -v '\.sh$') |while read f; do
	cppi < "$f" > "$f".cppi; mv "$f".cppi "$f"
done
2018-12-30 15:35:21 +00:00

48 lines
950 B
C

/*
* Copyright (c) 2016 Anchit Jain <anchitjain1234@gmail.com>
* Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "tests.h"
#include <asm/unistd.h>
#if defined __NR_chmod
# include <fcntl.h>
# include <stdio.h>
# include <unistd.h>
# include <errno.h>
int
main(void)
{
static const char fname[] = "chmod_test_file";
if (open(fname, O_CREAT|O_RDONLY, 0400) < 0)
perror_msg_and_fail("open");
long rc = syscall(__NR_chmod, fname, 0600);
printf("chmod(\"%s\", 0600) = %s\n", fname, sprintrc(rc));
if (unlink(fname))
perror_msg_and_fail("unlink");
rc = syscall(__NR_chmod, fname, 051);
printf("chmod(\"%s\", 051) = %s\n", fname, sprintrc(rc));
rc = syscall(__NR_chmod, fname, 004);
printf("chmod(\"%s\", 004) = %s\n", fname, sprintrc(rc));
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_chmod")
#endif