xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/mount/mount01.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
4  *               Nirmala Devi Dhanasekar <[email protected]>
5  * Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]>
6  */
7 
8 /*\
9  * [Description]
10  *
11  * Basic test that checks mount() syscall works on multiple filesystems.
12  */
13 
14 #include "tst_test.h"
15 #include <sys/mount.h>
16 
17 #define MNTPOINT "mntpoint"
18 
cleanup(void)19 static void cleanup(void)
20 {
21 	if (tst_is_mounted(MNTPOINT))
22 		SAFE_UMOUNT(MNTPOINT);
23 }
24 
run(void)25 static void run(void)
26 {
27 	TST_EXP_PASS(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL));
28 
29 	if (tst_is_mounted(MNTPOINT)) {
30 		tst_res(TPASS, "folder has been mounted");
31 		SAFE_UMOUNT(MNTPOINT);
32 	} else {
33 		tst_res(TFAIL, "folder has not been mounted");
34 	}
35 }
36 
37 static struct tst_test test = {
38 	.cleanup = cleanup,
39 	.test_all = run,
40 	.needs_root = 1,
41 	.format_device = 1,
42 	.all_filesystems = 1,
43 	.mntpoint = MNTPOINT,
44 	.skip_filesystems = (const char *const []){
45 		"ntfs",
46 		NULL
47 	},
48 };
49