]> granicus.if.org Git - strace/blob - tests/umount.c
tests: add umount.test and umount2.test
[strace] / tests / umount.c
1 #include <errno.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <sys/stat.h>
5 #include <sys/mount.h>
6 #include <sys/syscall.h>
7
8 #ifdef __NR_oldumount
9 # define TEST_SYSCALL_STR "oldumount"
10 #else
11 # if defined __NR_umount && defined __NR_umount2
12 #  define __NR_oldumount __NR_umount
13 #  define TEST_SYSCALL_STR "umount"
14 # endif
15 #endif
16
17 int
18 main(void)
19 {
20 #ifdef __NR_oldumount
21         static const char sample[] = "umount.sample";
22         if (mkdir(sample, 0700)) {
23                 perror(sample);
24                 return 77;
25         }
26         (void) syscall(__NR_oldumount, sample);
27         printf("%s(\"%s\") = -1 ", TEST_SYSCALL_STR, sample);
28         switch (errno) {
29                 case ENOSYS:
30                         printf("ENOSYS (%m)\n");
31                         break;
32                 case EPERM:
33                         printf("EPERM (%m)\n");
34                         break;
35                 default:
36                         printf("EINVAL (%m)\n");
37         }
38         (void) rmdir(sample);
39         puts("+++ exited with 0 +++");
40         return 0;
41 #else
42         return 77;
43 #endif
44 }