Fei Jie | a067b8d | 2016-03-31 16:06:49 +0800 | [diff] [blame^] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #ifdef __NR_sethostname |
| 5 | |
| 6 | # include <errno.h> |
| 7 | # include <stdio.h> |
| 8 | # include <unistd.h> |
| 9 | |
| 10 | int |
| 11 | main(void) |
| 12 | { |
| 13 | const char *hostname = NULL; |
| 14 | int rc = syscall(__NR_sethostname, hostname, 63); |
| 15 | const char *errno_text; |
| 16 | switch (errno) { |
| 17 | case ENOSYS: |
| 18 | errno_text = "ENOSYS"; |
| 19 | break; |
| 20 | case EPERM: |
| 21 | errno_text = "EPERM"; |
| 22 | break; |
| 23 | default: |
| 24 | errno_text = "EFAULT"; |
| 25 | } |
| 26 | printf("sethostname(NULL, %d) = %d %s (%m)\n", |
| 27 | 63, rc, errno_text); |
| 28 | |
| 29 | puts("+++ exited with 0 +++"); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | #else |
| 34 | |
| 35 | SKIP_MAIN_UNDEFINED("__NR_sethostname") |
| 36 | |
| 37 | #endif |