blob: 0d9c15f72c5fad2e162f7b8556632ed0a27a4259 [file] [log] [blame]
Dmitry V. Levinc6331882015-08-28 08:43:57 +00001#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
Gleb Fotengauer-Malinovskiy3af6aab2015-08-14 17:49:27 +02006#include <unistd.h>
7#include <sys/syscall.h>
8
9int
10main(void)
11{
12#ifdef __NR_readlink
Dmitry V. Levinc6331882015-08-28 08:43:57 +000013 static const char fname[] = "readlink.link";
14 unsigned char buf[31];
15 long rc;
16 unsigned int i;
Gleb Fotengauer-Malinovskiy3af6aab2015-08-14 17:49:27 +020017
Dmitry V. Levinc6331882015-08-28 08:43:57 +000018 rc = syscall(__NR_readlink, fname, buf, sizeof(buf));
19 if (rc < 0)
Gleb Fotengauer-Malinovskiy3af6aab2015-08-14 17:49:27 +020020 return 77;
21
Dmitry V. Levinc6331882015-08-28 08:43:57 +000022 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-Malinovskiy3af6aab2015-08-14 17:49:27 +020031 return 0;
32#else
33 return 77;
34#endif
35}