]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/mount-api-utils: cleanup
authorKarel Zak <kzak@redhat.com>
Thu, 9 Jun 2022 10:28:09 +0000 (12:28 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:53:12 +0000 (12:53 +0100)
* 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 <kzak@redhat.com>
configure.ac
include/mount-api-utils.h
libmount/src/version.c

index 9f15648f120538a640585f07bf5a206f3186bec9..8a6363f6ad3583afdcace3cd60b33f50f8e577e1 100644 (file)
@@ -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"])]
index fc8220168baa7b64f243dc2d27530c29debf0a09..09ea9eefacc773a781b61463e1b7080008c6613b 100644 (file)
@@ -5,14 +5,6 @@
 #include <sys/syscall.h>
 #include <linux/mount.h>
 
-/*
- * 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
 # 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 */
index 211bb9fe4feeb5b295855ba0a10623a7cc03ea9e..71fdc61b108da4983090ee024ae8ae6eb6eaa867 100644 (file)
@@ -19,6 +19,7 @@
 #include <ctype.h>
 
 #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