From: Karel Zak Date: Thu, 9 Jun 2022 10:28:09 +0000 (+0200) Subject: include/mount-api-utils: cleanup X-Git-Tag: v2.39-rc1~333 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e087a188e8b3045a471a35a9ab84801b93e4d9ca;p=thirdparty%2Futil-linux.git include/mount-api-utils: cleanup * use SYS_* macros * check for the syscalls in configure.ac * use SYS_* macros for #ifdefs * add "idmapping" to the list if libmount features Signed-off-by: Karel Zak --- diff --git a/configure.ac b/configure.ac index 9f15648f12..8a6363f6ad 100644 --- a/configure.ac +++ b/configure.ac @@ -622,6 +622,10 @@ UL_CHECK_SYSCALL([pidfd_open]) UL_CHECK_SYSCALL([pidfd_send_signal]) UL_CHECK_SYSCALL([close_range]) +UL_CHECK_SYSCALL([open_tree]) +UL_CHECK_SYSCALL([move_mount]) +UL_CHECK_SYSCALL([mount_setattr]) + AC_CHECK_FUNCS([isnan], [], [AC_CHECK_LIB([m], [isnan], [MATH_LIBS="-lm"])] [AC_CHECK_LIB([m], [__isnan], [MATH_LIBS="-lm"])] diff --git a/include/mount-api-utils.h b/include/mount-api-utils.h index fc8220168b..09ea9eefac 100644 --- a/include/mount-api-utils.h +++ b/include/mount-api-utils.h @@ -5,14 +5,6 @@ #include #include -/* - * Scope all of this beneath mount_setattr(). If this syscall is available all - * other syscalls must as well. Otherwise we're dealing with a partial backport - * of syscalls. - */ - -# if defined(SYS_mount_setattr) - /* Accepted by both open_tree() and mount_setattr(). */ #ifndef AT_RECURSIVE # define AT_RECURSIVE 0x8000 @@ -26,10 +18,10 @@ # define OPEN_TREE_CLOEXEC O_CLOEXEC #endif -#ifndef HAVE_OPEN_TREE +#if !defined(HAVE_OPEN_TREE) && defined(SYS_open_tree) static inline int open_tree(int dfd, const char *filename, unsigned int flags) { - return syscall(__NR_open_tree, dfd, filename, flags); + return syscall(SYS_open_tree, dfd, filename, flags); } #endif @@ -61,11 +53,11 @@ static inline int open_tree(int dfd, const char *filename, unsigned int flags) # define MOVE_MOUNT__MASK 0x00000077 #endif -#ifndef HAVE_MOVE_MOUNT +#if !defined(HAVE_MOVE_MOUNT) && defined(SYS_move_mount) static inline int move_mount(int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, unsigned int flags) { - return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, + return syscall(SYS_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags); } #endif @@ -116,17 +108,25 @@ struct mount_attr { }; #endif -#ifndef HAVE_MOUNT_SETATTR +#if !defined(HAVE_MOUNT_SETATTR) && defined(SYS_mount_setattr) static inline int mount_setattr(int dfd, const char *path, unsigned int flags, struct mount_attr *attr, size_t size) { - return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); + return syscall(SYS_mount_setattr, dfd, path, flags, attr, size); } #endif -#define UL_HAVE_MOUNT_API 1 -#endif /* SYS_mount_setattr */ +/* + * 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) + +# define UL_HAVE_MOUNT_API 1 +#endif #endif /* __linux__ */ #endif /* UTIL_LINUX_MOUNT_API_UTILS */ diff --git a/libmount/src/version.c b/libmount/src/version.c index 211bb9fe4f..71fdc61b10 100644 --- a/libmount/src/version.c +++ b/libmount/src/version.c @@ -19,6 +19,7 @@ #include #include "mountP.h" +#include "mount-api-utils.h" static const char *lib_version = LIBMOUNT_VERSION; static const char *lib_features[] = { @@ -37,6 +38,9 @@ static const char *lib_features[] = { #ifdef USE_LIBMOUNT_SUPPORT_NAMESPACES "namespaces", #endif +#ifdef UL_HAVE_MOUNT_API + "idmapping", +#endif #if !defined(NDEBUG) "assert", /* libc assert.h stuff */ #endif