Fei Jie | f914194 | 2016-04-21 15:53:51 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #ifdef __NR_access |
| 5 | |
Fei Jie | f914194 | 2016-04-21 15:53:51 +0800 | [diff] [blame] | 6 | # include <stdio.h> |
| 7 | # include <unistd.h> |
| 8 | |
| 9 | int |
| 10 | main(void) |
| 11 | { |
| 12 | static const char sample[] = "access_sample"; |
| 13 | |
| 14 | long rc = syscall(__NR_access, sample, F_OK); |
| 15 | printf("access(\"%s\", F_OK) = %ld %s (%m)\n", |
Dmitry V. Levin | 9f6611b | 2016-04-21 17:49:32 +0000 | [diff] [blame] | 16 | sample, rc, errno2name()); |
Fei Jie | f914194 | 2016-04-21 15:53:51 +0800 | [diff] [blame] | 17 | |
| 18 | rc = syscall(__NR_access, sample, R_OK|W_OK|X_OK); |
| 19 | printf("access(\"%s\", R_OK|W_OK|X_OK) = %ld %s (%m)\n", |
Dmitry V. Levin | 9f6611b | 2016-04-21 17:49:32 +0000 | [diff] [blame] | 20 | sample, rc, errno2name()); |
Fei Jie | f914194 | 2016-04-21 15:53:51 +0800 | [diff] [blame] | 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | #else |
| 26 | |
| 27 | SKIP_MAIN_UNDEFINED("__NR_access") |
| 28 | |
| 29 | #endif |