From: Karel Zak Date: Tue, 22 Nov 2022 10:41:58 +0000 (+0100) Subject: build-sys: add --disable-libmount-mountfd-support X-Git-Tag: v2.39-rc1~229 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9040c0900fd7e0b3f2a0773ac7c3904cd28263bd;p=thirdparty%2Futil-linux.git build-sys: add --disable-libmount-mountfd-support 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 --- diff --git a/configure.ac b/configure.ac index 2e73ea462c..6406f4d22e 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/include/mount-api-utils.h b/include/mount-api-utils.h index 4e2f23fc8a..fd65bfe74d 100644 --- a/include/mount-api-utils.h +++ b/include/mount-api-utils.h @@ -1,7 +1,8 @@ #ifndef UTIL_LINUX_MOUNT_API_UTILS #define UTIL_LINUX_MOUNT_API_UTILS -#if defined(__linux__) +#ifdef HAVE_MOUNTFD_API + #include #include @@ -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 */ diff --git a/libmount/src/hook_idmap.c b/libmount/src/hook_idmap.c index 35092aff3d..1a2e0562df 100644 --- a/libmount/src/hook_idmap.c +++ b/libmount/src/hook_idmap.c @@ -29,7 +29,7 @@ # include #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 */ diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c index 91bb4b6f55..299be87a88 100644 --- a/libmount/src/hook_mount.c +++ b/libmount/src/hook_mount.c @@ -46,7 +46,7 @@ #include "mountP.h" #include -#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 */ diff --git a/libmount/src/hook_mount_legacy.c b/libmount/src/hook_mount_legacy.c index 86069dd909..b268bdecb2 100644 --- a/libmount/src/hook_mount_legacy.c +++ b/libmount/src/hook_mount_legacy.c @@ -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; diff --git a/libmount/src/hook_subdir.c b/libmount/src/hook_subdir.c index 74120f6d74..2b7a95b341 100644 --- a/libmount/src/hook_subdir.c +++ b/libmount/src/hook_subdir.c @@ -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); diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c index 7b1ab7f5a2..539d440f65 100644 --- a/libmount/src/hooks.c +++ b/libmount/src/hooks.c @@ -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 diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index d2fced092d..a340048362 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -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() */ diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c index 2f6e1f4073..5bd72d24d2 100644 --- a/libmount/src/optlist.c +++ b/libmount/src/optlist.c @@ -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) diff --git a/libmount/src/version.c b/libmount/src/version.c index ce6b6b2320..948b1a01de 100644 --- a/libmount/src/version.c +++ b/libmount/src/version.c @@ -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)