]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: add --disable-libmount-mountfd-support
authorKarel Zak <kzak@redhat.com>
Tue, 22 Nov 2022 10:41:58 +0000 (11:41 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:58:42 +0000 (12:58 +0100)
We need to disable support for new kernel API in libmount to test the
old code on new kernels (or maybe also for conservative users).

The new configure option disable only mount(2)-like operations, the
another stuff (like IDs mapping) is not affected.

Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
include/mount-api-utils.h
libmount/src/hook_idmap.c
libmount/src/hook_mount.c
libmount/src/hook_mount_legacy.c
libmount/src/hook_subdir.c
libmount/src/hooks.c
libmount/src/mountP.h
libmount/src/optlist.c
libmount/src/version.c

index 2e73ea462cd5f9d4abc21bf3d83f385c98c558b9..6406f4d22e2d619dc9ed282213d3b74322f0c799 100644 (file)
@@ -635,6 +635,20 @@ UL_CHECK_SYSCALL([mount_setattr])
 UL_CHECK_SYSCALL([move_mount])
 UL_CHECK_SYSCALL([open_tree])
 
+AS_IF([test "x$ul_cv_syscall_fsconfig" = xno ||
+       test "x$ul_cv_syscall_fsmount" = xno ||
+       test "x$ul_cv_syscall_fsopen" = xno ||
+       test "x$ul_cv_syscall_fspick" = xno ||
+       test "x$ul_cv_syscall_mount_setattr" = xno ||
+       test "x$ul_cv_syscall_move_mount" = xno ||
+       test "x$ul_cv_syscall_open_tree" = xno],
+   [
+       have_mountfd_api="no"
+   ],[
+        have_mountfd_api="yes"
+       AC_DEFINE([HAVE_MOUNTFD_API], [1], [Define to 1 if you want mount API based on FDs.])
+   ])
+
 
 AC_CHECK_FUNCS([isnan], [],
        [AC_CHECK_LIB([m], [isnan], [MATH_LIBS="-lm"])]
@@ -1196,6 +1210,19 @@ AC_ARG_ENABLE([libmount-support-mtab],
   [], [enable_libmount_support_mtab=no]
 )
 
+AC_ARG_ENABLE([libmount-mountfd-support],
+  AS_HELP_STRING([--disable-libmount-mountfd-support], [do not use new mount API based on FDs]),
+  [], [enable_libmount_mountfd_support=check]
+)
+UL_BUILD_INIT([libmount_mountfd_support])
+UL_REQUIRES_BUILD([libmount_mountfd_support], [libmount])
+UL_REQUIRES_LINUX([libmount_mountfd_support])
+UL_REQUIRES_HAVE([libmount_mountfd_support], [mountfd_api], [mount FDs based API])
+AS_IF([test "x$build_libmount_mountfd_support" = xyes ], [
+  AC_DEFINE([USE_LIBMOUNT_MOUNTFD_SUPPORT], [1], [Enable support for new mount FD based kernel API])
+])
+
+
 dnl
 dnl libsmartcols
 dnl
index 4e2f23fc8a5eda62b1829d3d23a3e233a6302ff8..fd65bfe74d3fbe1c5cef04653f87772c05db0284 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef UTIL_LINUX_MOUNT_API_UTILS
 #define UTIL_LINUX_MOUNT_API_UTILS
 
-#if defined(__linux__)
+#ifdef HAVE_MOUNTFD_API
+
 #include <sys/syscall.h>
 #include <linux/mount.h>
 
@@ -186,22 +187,6 @@ static inline int fspick(int dfd, const char *pathname, unsigned int flags)
 }
 #endif
 
-
-/*
- * UL_HAVE_MOUNT_API is used by applications to check that all new mount API is
- * avalable.
- */
-#if defined(SYS_open_tree) && \
-    defined(SYS_mount_setattr) && \
-    defined(SYS_move_mount) && \
-    defined(SYS_fsconfig) && \
-    defined(SYS_fsopen) && \
-    defined(SYS_fsmount) && \
-    defined(SYS_fspick)
-
-# define UL_HAVE_MOUNT_API 1
-#endif
-
-#endif /* __linux__ */
+#endif /* HAVE_MOUNTFD_API */
 #endif /* UTIL_LINUX_MOUNT_API_UTILS */
 
index 35092aff3d915b8307b0e492170c7156094fc64b..1a2e0562dfd81aebc46a6a6cc43abbdabef75cf4 100644 (file)
@@ -29,7 +29,7 @@
 # include <linux/nsfs.h>
 #endif
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef HAVE_MOUNTFD_API
 
 typedef enum idmap_type_t {
        ID_TYPE_UID,    /* uidmap entry */
@@ -486,4 +486,4 @@ const struct libmnt_hookset hookset_idmap =
        .deinit = hookset_deinit
 };
 
-#endif /* UL_HAVE_MOUNT_API */
+#endif /* HAVE_MOUNTFD_API */
index 91bb4b6f55092062c8034ca37fadd9e2e65ac3cb..299be87a882b98bdb1769e303a641db8db23601b 100644 (file)
@@ -46,7 +46,7 @@
 #include "mountP.h"
 #include <inttypes.h>
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
 
 #define get_sysapi(_cxt) mnt_context_get_sysapi(_cxt)
 
@@ -590,4 +590,4 @@ const struct libmnt_hookset hookset_mount =
 
        .deinit = hookset_deinit
 };
-#endif /* UL_HAVE_MOUNT_API */
+#endif /* USE_LIBMOUNT_MOUNTFD_SUPPORT */
index 86069dd909c6fc5f8a1e2bfde7846af75721099a..b268bdecb2b4e8fb90fe741cd55643c03b368590 100644 (file)
@@ -282,7 +282,7 @@ static int hook_prepare(struct libmnt_context *cxt,
        assert(cxt);
        assert(hs == &hookset_mount_legacy);
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
        /* do nothing when a new __mount succesfully registred */
        if (mnt_context_has_hook(cxt, &hookset_mount, 0, NULL))
                return 0;
index 74120f6d74fb252aed8b9c5abef0483690cd83da..2b7a95b34113f17856799cf8dbec65e65dac18f4 100644 (file)
@@ -155,7 +155,7 @@ static int do_mount_subdir(
 {
        int rc = 0;
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
        struct libmnt_sysapi *api;
 
        api = mnt_context_get_sysapi(cxt);
index 7b1ab7f5a24d7100e7441afa6ef6e96efe4e086c..539d440f652de170cef5a0894cdf65ace84a2da5 100644 (file)
@@ -39,11 +39,11 @@ static const struct libmnt_hookset *hooksets[] =
 #endif
        &hookset_mkdir,
        &hookset_subdir,
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
        &hookset_mount,
 #endif
        &hookset_mount_legacy,
-#ifdef UL_HAVE_MOUNT_API
+#ifdef HAVE_MOUNTFD_API
        &hookset_idmap,
 #endif
        &hookset_owner
index d2fced092d9c94bd513147a9ccb02b16ce60fa5f..a34004836288173188e088cb6fbdb384f826f925 100644 (file)
@@ -638,7 +638,7 @@ extern int mnt_update_already_done(struct libmnt_update *upd,
 extern uint64_t btrfs_get_default_subvol_id(const char *path);
 #endif
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
 /* fsconfig/fsopen based stuff */
 struct libmnt_sysapi {
        int     fd_fs;          /* FD from fsopen() or fspick() */
index 2f6e1f40730e27fc9f31f3428ad6a1bdda72462a..5bd72d24d2cae76a3d770acae46478753b05c006 100644 (file)
@@ -746,7 +746,7 @@ int mnt_optlist_get_flags(struct libmnt_optlist *ls, unsigned long *flags,
        return 0;
 }
 
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
 static inline uint64_t flag_to_attr(unsigned long flag)
 {
        switch (flag) {
@@ -775,7 +775,7 @@ static inline uint64_t flag_to_attr(unsigned long flag)
  * Like mnt_optlist_get_flags() for VFS flags, but converts classic MS_* flags to
  * new MOUNT_ATTR_*
  */
-#ifdef UL_HAVE_MOUNT_API
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
 int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *clr)
 {
        struct libmnt_iter itr;
@@ -821,7 +821,7 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls __attribute__((__unused__)),
 {
        return 0;
 }
-#endif /* UL_HAVE_MOUNT_API */
+#endif /* USE_LIBMOUNT_MOUNTFD_SUPPORT */
 
 int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr,
                        const struct libmnt_optmap *map, unsigned int what)
index ce6b6b23203893517845fb268646ab11bf9973a4..948b1a01de98c2b68a07eb0cd88bcccdc3fa2d67 100644 (file)
@@ -38,8 +38,10 @@ static const char *lib_features[] = {
 #ifdef USE_LIBMOUNT_SUPPORT_NAMESPACES
        "namespaces",
 #endif
-#ifdef UL_HAVE_MOUNT_API
+#ifdef HAVE_MOUNTFD_API
        "idmapping",
+#endif
+#ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
        "fd-based-mount",
 #endif
 #if !defined(NDEBUG)