• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <nirmala.devi@wipro.com>
5  *
6  * Phase I test for the umount(2) system call.
7  * It is intended to provide a limited exposure of the system call.
8  */
9 
10 #include <errno.h>
11 #include <sys/mount.h>
12 #include "tst_test.h"
13 
14 #define MNTPOINT	"mntpoint"
15 
16 static int mount_flag;
17 
verify_umount(void)18 static void verify_umount(void)
19 {
20 	if (mount_flag != 1) {
21 		SAFE_MOUNT(tst_device->dev, MNTPOINT,
22 			tst_device->fs_type, 0, NULL);
23 		mount_flag = 1;
24 	}
25 
26 	TEST(umount(MNTPOINT));
27 
28 	if (TST_RET != 0 && TST_ERR == EBUSY) {
29 		tst_res(TINFO, "umount() Failed with EBUSY "
30 			"possibly some daemon (gvfsd-trash) "
31 			"is probing newly mounted dirs");
32 	}
33 
34 	if (TST_RET != 0) {
35 		tst_res(TFAIL | TTERRNO, "umount() Failed");
36 		return;
37 	}
38 
39 	tst_res(TPASS, "umount() Passed");
40 	mount_flag = 0;
41 }
42 
setup(void)43 static void setup(void)
44 {
45 	SAFE_MKDIR(MNTPOINT, 0775);
46 }
47 
cleanup(void)48 static void cleanup(void)
49 {
50 	if (mount_flag)
51 		tst_umount(MNTPOINT);
52 }
53 
54 static struct tst_test test = {
55 	.needs_root = 1,
56 	.format_device = 1,
57 	.setup = setup,
58 	.cleanup = cleanup,
59 	.test_all = verify_umount,
60 };
61