1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
4 * Author: Nirmala Devi Dhanasekar <[email protected]>
5 * Copyright (c) Linux Test Project, 2002-2023
6 */
7
8 /*\
9 * [Description]
10 *
11 * Check the basic functionality of the umount(2) system call.
12 */
13
14 #include <sys/mount.h>
15 #include "tst_test.h"
16
17 #define MNTPOINT "mntpoint"
18
19 static int mount_flag;
20
verify_umount(void)21 static void verify_umount(void)
22 {
23 if (mount_flag != 1) {
24 SAFE_MOUNT(tst_device->dev, MNTPOINT,
25 tst_device->fs_type, 0, NULL);
26 mount_flag = 1;
27 }
28
29 TST_EXP_PASS(umount(MNTPOINT));
30
31 if (TST_RET != 0 && TST_ERR == EBUSY) {
32 tst_res(TINFO, "umount() Failed with EBUSY "
33 "possibly some daemon (gvfsd-trash) "
34 "is probing newly mounted dirs");
35 }
36
37 mount_flag = 0;
38 }
39
setup(void)40 static void setup(void)
41 {
42 SAFE_MKDIR(MNTPOINT, 0775);
43 }
44
cleanup(void)45 static void cleanup(void)
46 {
47 if (mount_flag)
48 tst_umount(MNTPOINT);
49 }
50
51 static struct tst_test test = {
52 .needs_root = 1,
53 .format_device = 1,
54 .setup = setup,
55 .cleanup = cleanup,
56 .test_all = verify_umount,
57 };
58