• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
4  */
5 
6 /*\
7  * [Description]
8  *
9  * This test verifies that statmount() is working with no mask flags.
10  *
11  * [Algorithm]
12  *
13  * - create a mount point
14  * - run statmount() on the mount point without giving any mask
15  * - read results and check that mask and size are correct
16  */
17 
18 #define _GNU_SOURCE
19 
20 #include "statmount.h"
21 #include "lapi/stat.h"
22 #include "lapi/sched.h"
23 
24 #define MNTPOINT "mntpoint"
25 
26 static uint64_t mntpoint_id;
27 static struct statmount *st_mount;
28 
run(void)29 static void run(void)
30 {
31 	memset(st_mount, 0, sizeof(struct statmount));
32 
33 	TST_EXP_PASS(statmount(mntpoint_id, 0, st_mount, sizeof(struct statmount), 0));
34 
35 	if (!TST_PASS)
36 		return;
37 
38 	TST_EXP_EQ_LI(st_mount->size, sizeof(struct statmount));
39 	TST_EXP_EQ_LI(st_mount->mask, 0);
40 	TST_EXP_EQ_LI(st_mount->sb_dev_major, 0);
41 	TST_EXP_EQ_LI(st_mount->sb_dev_minor, 0);
42 	TST_EXP_EQ_LI(st_mount->sb_magic, 0);
43 	TST_EXP_EQ_LI(st_mount->sb_flags, 0);
44 	TST_EXP_EQ_LI(st_mount->fs_type, 0);
45 	TST_EXP_EQ_LI(st_mount->mnt_id, 0);
46 	TST_EXP_EQ_LI(st_mount->mnt_parent_id, 0);
47 	TST_EXP_EQ_LI(st_mount->mnt_id_old, 0);
48 	TST_EXP_EQ_LI(st_mount->mnt_parent_id_old, 0);
49 	TST_EXP_EQ_LI(st_mount->mnt_attr, 0);
50 	TST_EXP_EQ_LI(st_mount->mnt_propagation, 0);
51 	TST_EXP_EQ_LI(st_mount->mnt_peer_group, 0);
52 	TST_EXP_EQ_LI(st_mount->mnt_master, 0);
53 	TST_EXP_EQ_LI(st_mount->propagate_from, 0);
54 	TST_EXP_EQ_LI(st_mount->mnt_root, 0);
55 	TST_EXP_EQ_LI(st_mount->mnt_point, 0);
56 }
57 
setup(void)58 static void setup(void)
59 {
60 	struct ltp_statx sx;
61 
62 	SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx);
63 
64 	mntpoint_id = sx.data.stx_mnt_id;
65 }
66 
67 static struct tst_test test = {
68 	.test_all = run,
69 	.setup = setup,
70 	.min_kver = "6.8",
71 	.mount_device = 1,
72 	.mntpoint = MNTPOINT,
73 	.bufs = (struct tst_buffers []) {
74 		{&st_mount, .size = sizeof(struct statmount)},
75 		{}
76 	}
77 };
78