[LTP] 回复: [PATCH v2] syscalls/mount_setattr01: Add basic functional test

Petr Vorel pvorel@suse.cz
Fri Apr 22 16:11:48 CEST 2022


Hi Chen,

> > I guess we need SAFE_ variants for not having to check it all the time.

> It's hard for a SAFE_MOUNT_SETATTR:
> mount_setattr(2) need:
> #include <linux/mount.h> /* Definition of MOUNT_ATTR_* constants */

> But linux/mount.h have some conflicts with sys/mount.h, which is widely used in LTP.
> If we really want SAFE_MOUNT_SETATTR, we may need a big refactor.

Well, you don't have to bother with SAFE_MOUNT_SETATTR() unless you have time
for it. That will not block this patchset.

FYI I did some cleanup of include/lapi/mount.h and include/lapi/fsmount.h:
c0cb5d1962 ("lapi/mount.h: Include kernel/libc header")
8ae596f8b5 ("lapi/fsmount.h: Include lapi/mount.h instead libc header")

FYI we include kernel header and if missing, we include libc header:
#ifdef HAVE_LINUX_MOUNT_H
# include <linux/mount.h>
#else
# include <sys/mount.h>
#endif

If kernel header is old enough (theoretically we support compilation on 3.10 [1]),
we just include it and don't bother about checks.

If you want to work on SAFE_*(): not only SAFE_MOUNT_SETATTR(), but more
functions could be defined:
SAFE_MOVE_MOUNT() (could be used in fs{config,mount,open} tests), maybe
SAFE_OPEN_TREE() (it'd be used only in this test as open_tree tests should
probably keep using TEST(open_tree(...)).

I'd put it/them into new file lib/tst_safe_fsmount.c and include/tst_safe_fsmount.h.

NOTE: Although we have SAFE_MOUNT() in lib/safe_macros.c, IMHO we should keep it
there, instead of creating lib/tst_safe_mount.c, because lib/safe_macros.c
supports also legacy API (which we don't want to continue developing) and we
don't want to put many include/tst_safe_mount.h.

TODO for myself: SAFE_STATVFS() and SAFE_FSTATVFS()


> Sure, I'll post v3 soon.
+1

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/wiki/Supported-kernel,-libc,-toolchain-versions


More information about the ltp mailing list