1 /*
2 * Copyright (c) 2015-2021 Dmitry V. Levin <ldv@strace.io>
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #include "tests.h"
9 #include <stdio.h>
10 #include <unistd.h>
11 #include <sys/stat.h>
12 #include <sys/mount.h>
13 #include "scno.h"
14
15 #if defined __NR_umount2 && (!defined __NR_umount || __NR_umount2 != __NR_umount)
16 # define TEST_SYSCALL_NR __NR_umount2
17 # define TEST_SYSCALL_STR "umount2"
18 #else
19 # define TEST_SYSCALL_NR __NR_umount
20 # define TEST_SYSCALL_STR "umount"
21 #endif
22
23 int
24 main(void)
25 {
26 static const char sample[] = "umount2.sample";
27 if (mkdir(sample, 0700))
28 perror_msg_and_fail("mkdir: %s", sample);
29 long ret = syscall(TEST_SYSCALL_NR, sample, 31);
30 printf("%s(\"%s\", MNT_FORCE|MNT_DETACH|MNT_EXPIRE|UMOUNT_NOFOLLOW|0x10)"
31 " = %s\n", TEST_SYSCALL_STR, sample, sprintrc(ret));
32 if (rmdir(sample))
33 perror_msg_and_fail("rmdir: %s", sample);
34 puts("+++ exited with 0 +++");
35 return 0;
36 }