diff options
Diffstat (limited to 'src/tools/syscall_test.c')
-rw-r--r-- | src/tools/syscall_test.c | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/tools/syscall_test.c b/src/tools/syscall_test.c deleted file mode 100644 index b3f43c755..000000000 --- a/src/tools/syscall_test.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <stdio.h> | ||
3 | #include <unistd.h> | ||
4 | #include <sys/types.h> | ||
5 | #include <sys/socket.h> | ||
6 | #include <linux/netlink.h> | ||
7 | #include <net/ethernet.h> | ||
8 | #include <sys/mount.h> | ||
9 | |||
10 | int main(int argc, char **argv) { | ||
11 | if (argc != 2) { | ||
12 | printf("Usage: test [sleep|socket|mkdir|mount]\n"); | ||
13 | return 1; | ||
14 | } | ||
15 | |||
16 | if (strcmp(argv[1], "sleep") == 0) { | ||
17 | printf("before sleep\n"); | ||
18 | sleep(1); | ||
19 | printf("after sleep\n"); | ||
20 | } | ||
21 | else if (strcmp(argv[1], "socket") == 0) { | ||
22 | int sock; | ||
23 | |||
24 | printf("testing socket AF_INET\n"); | ||
25 | if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { | ||
26 | perror("socket"); | ||
27 | } | ||
28 | else | ||
29 | close(sock); | ||
30 | |||
31 | printf("testing socket AF_INET6\n"); | ||
32 | if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0) { | ||
33 | perror("socket"); | ||
34 | } | ||
35 | else | ||
36 | close(sock); | ||
37 | |||
38 | printf("testing socket AF_NETLINK\n"); | ||
39 | if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) { | ||
40 | perror("socket"); | ||
41 | } | ||
42 | else | ||
43 | close(sock); | ||
44 | |||
45 | printf("testing socket AF_UNIX\n"); | ||
46 | if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { | ||
47 | perror("socket"); | ||
48 | } | ||
49 | else | ||
50 | close(sock); | ||
51 | |||
52 | // root needed to be able to handle this | ||
53 | printf("testing socket AF_PACKETX\n"); | ||
54 | if ((sock = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ARP))) < 0) { | ||
55 | perror("socket"); | ||
56 | } | ||
57 | else | ||
58 | close(sock); | ||
59 | printf("after socket\n"); | ||
60 | } | ||
61 | else if (strcmp(argv[1], "mkdir") == 0) { | ||
62 | printf("before mkdir\n"); | ||
63 | mkdir("tmp", 0777); | ||
64 | printf("after mkdir\n"); | ||
65 | } | ||
66 | else if (strcmp(argv[1], "mount") == 0) { | ||
67 | printf("before mount\n"); | ||
68 | if (mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC, "mode=755,gid=0") < 0) { | ||
69 | perror("mount"); | ||
70 | } | ||
71 | printf("after mount\n"); | ||
72 | } | ||
73 | else { | ||
74 | fprintf(stderr, "Error: invalid argument\n"); | ||
75 | return 1; | ||
76 | } | ||
77 | return 0; | ||
78 | } | ||