]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Merge branch 'PR/libmount-stat.h'
authorKarel Zak <kzak@redhat.com>
Mon, 11 Sep 2023 07:11:41 +0000 (09:11 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Sep 2023 07:11:41 +0000 (09:11 +0200)
configure.ac
include/fileutils.h
libmount/src/hook_mount.c
libmount/src/utils.c
libmount/src/version.c
meson.build

index af58cb20e2b314f2768c425990e2f7827162206d..22e579c3916d4cb69326f5af401181be8e635480 100644 (file)
@@ -326,7 +326,6 @@ AC_CHECK_HEADERS([ \
        linux/nsfs.h \
        linux/pr.h \
        linux/raw.h \
-       linux/stat.h \
        linux/securebits.h \
        linux/tiocl.h \
        linux/version.h \
@@ -518,7 +517,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 ])
 
 AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]])
-AC_CHECK_TYPES([struct statx], [], [], [[#include <linux/stat.h>]])
 AC_CHECK_TYPES([enum fsconfig_command], [], [], [[#include <linux/mount.h>]])
 
 AC_CHECK_MEMBERS([struct termios.c_line],,,
@@ -527,8 +525,9 @@ AC_CHECK_MEMBERS([struct termios.c_line],,,
 AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec],,,
     [[#include <sys/stat.h>]])
 
+AC_CHECK_TYPES([struct statx], [], [], [[#include <sys/stat.h>]])
 AC_CHECK_MEMBERS([struct statx.stx_mnt_id],,,
-    [[#include <linux/stat.h>]])
+    [[#include <sys/stat.h>]])
 
 AC_CHECK_DECLS([_NL_TIME_WEEK_1STDAY],[],[],[[#include <langinfo.h>]])
 
index a5fe517266f516b4f19d2e5961bbf29dbf90e646..538eab0b74eb250f767926290728a053396a63ca 100644 (file)
@@ -94,13 +94,13 @@ static inline int close_range(unsigned int first, unsigned int last, int flags)
 #  define HAVE_CLOSE_RANGE 1
 # endif        /* SYS_close_range */
 
-# if !defined(HAVE_STATX) && defined(HAVE_STRUCT_STATX) && defined(SYS_statx) && defined(HAVE_LINUX_STAT_H)
-#  include <linux/stat.h>
+# if !defined(HAVE_STATX) && defined(HAVE_STRUCT_STATX) && defined(SYS_statx)
 static inline int statx(int fd, const char *restrict path, int flags,
                    unsigned int mask, struct statx *stx)
 {
        return syscall(SYS_statx, fd, path, flags, mask, stx);
 }
+#  define HAVE_STATX 1
 # endif /* SYS_statx */
 
 #endif /* HAVE_SYS_SYSCALL_H */
index 056338c491424b5d68528a9c7e4259cc6346cdec..4b2a534f74e280e0dab27acf6cb80bab25634500 100644 (file)
@@ -294,17 +294,18 @@ static int hook_create_mount(struct libmnt_context *cxt,
                /* cleanup after fail (libmount may only try the FS type) */
                close_sysapi_fds(api);
 
-#if defined(HAVE_STRUCT_STATX) && defined(HAVE_STRUCT_STATX_STX_MNT_ID)
+#if defined(HAVE_STATX) && defined(HAVE_STRUCT_STATX) && defined(HAVE_STRUCT_STATX_STX_MNT_ID)
        if (!rc && cxt->fs) {
                struct statx st;
 
                rc = statx(api->fd_tree, "", AT_EMPTY_PATH, STATX_MNT_ID, &st);
-               cxt->fs->id = (int) st.stx_mnt_id;
-
-               if (cxt->update) {
-                       struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
-                       if (fs)
-                               fs->id = cxt->fs->id;
+               if (rc == 0) {
+                       cxt->fs->id = (int) st.stx_mnt_id;
+                       if (cxt->update) {
+                               struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
+                               if (fs)
+                                       fs->id = cxt->fs->id;
+                       }
                }
        }
 #endif
index 1d3f4abcecec73d2be5708ee0c07b6ba749312cd..3817b392711c89e3f272749d34fe853f0f6da729 100644 (file)
@@ -111,7 +111,7 @@ static int safe_stat(const char *target, struct stat *st, int nofollow)
 
        memset(st, 0, sizeof(struct stat));
 
-#if defined(AT_STATX_DONT_SYNC) && defined (HAVE_STRUCT_STATX)
+#if defined(HAVE_STATX) && defined(HAVE_STRUCT_STATX) && defined(AT_STATX_DONT_SYNC)
        {
                int rc;
                struct statx stx = { 0 };
index 8e5f165f4920a0eae6aa5042621842ef62deebca..894c20c5cb88726d7165b35af6b715905b1dc048 100644 (file)
@@ -44,6 +44,9 @@ static const char *lib_features[] = {
 #ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
        "fd-based-mount",
 #endif
+#if defined(HAVE_STATX) && defined(HAVE_STRUCT_STATX) && defined(AT_STATX_DONT_SYNC)
+       "statx",
+#endif
 #if !defined(NDEBUG)
        "assert",       /* libc assert.h stuff */
 #endif
index e067ecc34f9163ac2d0ae966b9ca855a3c608d9a..8e3d6bb1d93dfc42afc4e1514bbd5b2a9fdeb630 100644 (file)
@@ -79,7 +79,7 @@ have_mountfd_api = cc.sizeof('struct mount_attr', prefix : '#include <linux/moun
 conf.set('HAVE_STRUCT_MOUNT_ATTR', have_mountfd_api ? 1 : false)
 conf.set('HAVE_MOUNTFD_API', have_mountfd_api ? 1 : false)
 
-have_struct_statx = cc.sizeof('struct statx', prefix : '#include <linux/stat.h>') > 0
+have_struct_statx = cc.sizeof('struct statx', prefix : '#include <sys/stat.h>') > 0
 conf.set('HAVE_STRUCT_STATX', have_struct_statx ? 1 : false)
 
 build_libmount = not get_option('build-libmount').disabled()
@@ -177,7 +177,6 @@ headers = '''
         linux/nsfs.h
         linux/mount.h
         linux/pr.h
-        linux/stat.h
         linux/securebits.h
         linux/tiocl.h
         linux/version.h
@@ -640,7 +639,7 @@ have = cc.has_member('struct stat', 'st_mtim.tv_nsec',
 conf.set('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC', have ? 1 : false)
 
 have = cc.has_member('struct statx', 'stx_mnt_id',
-                     prefix : '#include <linux/stat.h>')
+                     prefix : '#include <sys/stat.h>')
 conf.set('HAVE_STRUCT_STATX_STX_MNT_ID', have ? 1 : false)
 
 # replacement for AC_STRUCT_TIMEZONE