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 correctly reading name of the
10 * filesystem type using STATMOUNT_FS_TYPE.
11 *
12 * [Algorithm]
13 *
14 * - create a mount point
15 * - run statmount() on the mount point using STATMOUNT_FS_TYPE
16 * - read results and check if contain the name of the filesystem
17 */
18
19 #define _GNU_SOURCE
20
21 #include "statmount.h"
22 #include "lapi/stat.h"
23 #include "lapi/sched.h"
24
25 #define MNTPOINT "mntpoint"
26 #define SM_SIZE (1 << 10)
27
28 static uint64_t root_id;
29 static struct statmount *st_mount;
30
run(void)31 static void run(void)
32 {
33 memset(st_mount, 0, SM_SIZE);
34
35 TST_EXP_PASS(statmount(root_id, STATMOUNT_FS_TYPE, st_mount,
36 SM_SIZE, 0));
37
38 if (!TST_PASS)
39 return;
40
41 TST_EXP_EQ_LI(st_mount->mask, STATMOUNT_FS_TYPE);
42 TST_EXP_EQ_STR(st_mount->str + st_mount->fs_type, tst_device->fs_type);
43 }
44
setup(void)45 static void setup(void)
46 {
47 struct ltp_statx sx;
48
49 SAFE_STATX(AT_FDCWD, MNTPOINT, 0, STATX_MNT_ID_UNIQUE, &sx);
50 root_id = sx.data.stx_mnt_id;
51 }
52
53 static struct tst_test test = {
54 .test_all = run,
55 .setup = setup,
56 .min_kver = "6.8",
57 .mount_device = 1,
58 .mntpoint = MNTPOINT,
59 .all_filesystems = 1,
60 .skip_filesystems = (const char *const []) {
61 "fuse",
62 NULL
63 },
64 .bufs = (struct tst_buffers []) {
65 {&st_mount, .size = SM_SIZE},
66 {}
67 }
68 };
69