Dmitry V. Levin | c633188 | 2015-08-28 08:43:57 +0000 | [diff] [blame] | 1 | #ifdef HAVE_CONFIG_H |
| 2 | # include "config.h" |
| 3 | #endif |
| 4 | |
| 5 | #include <stdio.h> |
Gleb Fotengauer-Malinovskiy | 3af6aab | 2015-08-14 17:49:27 +0200 | [diff] [blame] | 6 | #include <unistd.h> |
| 7 | #include <sys/syscall.h> |
| 8 | |
| 9 | int |
| 10 | main(void) |
| 11 | { |
| 12 | #ifdef __NR_readlink |
Dmitry V. Levin | c633188 | 2015-08-28 08:43:57 +0000 | [diff] [blame] | 13 | static const char fname[] = "readlink.link"; |
| 14 | unsigned char buf[31]; |
| 15 | long rc; |
| 16 | unsigned int i; |
Gleb Fotengauer-Malinovskiy | 3af6aab | 2015-08-14 17:49:27 +0200 | [diff] [blame] | 17 | |
Dmitry V. Levin | c633188 | 2015-08-28 08:43:57 +0000 | [diff] [blame] | 18 | rc = syscall(__NR_readlink, fname, buf, sizeof(buf)); |
| 19 | if (rc < 0) |
Gleb Fotengauer-Malinovskiy | 3af6aab | 2015-08-14 17:49:27 +0200 | [diff] [blame] | 20 | return 77; |
| 21 | |
Dmitry V. Levin | c633188 | 2015-08-28 08:43:57 +0000 | [diff] [blame] | 22 | printf("readlink(\""); |
| 23 | for (i = 0; fname[i]; ++i) |
| 24 | printf("\\x%02x", (int) (unsigned char) fname[i]); |
| 25 | printf("\", \""); |
| 26 | for (i = 0; i < 3; ++i) |
| 27 | printf("\\x%02x", (int) buf[i]); |
| 28 | printf("\"..., %zu) = %ld\n", sizeof(buf), rc); |
| 29 | |
| 30 | puts("+++ exited with 0 +++"); |
Gleb Fotengauer-Malinovskiy | 3af6aab | 2015-08-14 17:49:27 +0200 | [diff] [blame] | 31 | return 0; |
| 32 | #else |
| 33 | return 77; |
| 34 | #endif |
| 35 | } |