• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * You should have received a copy of the GNU General Public License along
13  * with this program; if not, write the Free Software Foundation, Inc.,
14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * AUTHOR		: Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
17  *
18  * DESCRIPTION
19  *	This is a Phase I test for the umount(2) system call.
20  *	It is intended to provide a limited exposure of the system call.
21  *****************************************************************************/
22 
23 #include <errno.h>
24 #include <sys/mount.h>
25 #include "tst_test.h"
26 
27 #define MNTPOINT	"mntpoint"
28 
29 static int mount_flag;
30 
verify_umount(void)31 static void verify_umount(void)
32 {
33 	if (mount_flag != 1) {
34 		SAFE_MOUNT(tst_device->dev, MNTPOINT,
35 			tst_device->fs_type, 0, NULL);
36 		mount_flag = 1;
37 	}
38 
39 	TEST(umount(MNTPOINT));
40 
41 	if (TST_RET != 0 && TST_ERR == EBUSY) {
42 		tst_res(TINFO, "umount() Failed with EBUSY "
43 			"possibly some daemon (gvfsd-trash) "
44 			"is probing newly mounted dirs");
45 	}
46 
47 	if (TST_RET != 0) {
48 		tst_res(TFAIL | TTERRNO, "umount() Failed");
49 		return;
50 	}
51 
52 	tst_res(TPASS, "umount() Passed");
53 	mount_flag = 0;
54 }
55 
setup(void)56 static void setup(void)
57 {
58 	SAFE_MKDIR(MNTPOINT, 0775);
59 }
60 
cleanup(void)61 static void cleanup(void)
62 {
63 	if (mount_flag)
64 		tst_umount(MNTPOINT);
65 }
66 
67 static struct tst_test test = {
68 	.needs_root = 1,
69 	.needs_tmpdir = 1,
70 	.format_device = 1,
71 	.setup = setup,
72 	.cleanup = cleanup,
73 	.test_all = verify_umount,
74 };
75