]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dirent: conditionalize dirent assert based on dirent64 existence
authorSam James <sam@gentoo.org>
Wed, 10 May 2023 00:47:13 +0000 (01:47 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 10 May 2023 06:05:18 +0000 (15:05 +0900)
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: https://github.com/systemd/systemd/pull/25809
meson.build
src/basic/dirent-util.h

index f6c7279fd526a78e63165294bd95c5c5aa00c846..92ad879f64a3f4c6f055ac71dc47884c810f1fb0 100644 (file)
@@ -544,6 +544,7 @@ assert(long_max > 100000)
 conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
 
 decl_headers = '''
+#include <dirent.h>
 #include <uchar.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
@@ -553,6 +554,7 @@ foreach decl : ['char16_t',
                 'char32_t',
                 'struct mount_attr',
                 'struct statx',
+                'struct dirent64',
                ]
 
         # We get -1 if the size cannot be determined
index 0f1fb231190a891a21978f43e4a40f4e0c9d3ee8..508d34a44f0464aceb856948c7bea60bcb6a18d4 100644 (file)
@@ -36,6 +36,7 @@ struct dirent *readdir_no_dot(DIR *dirp);
 /* Only if 64bit off_t is enabled struct dirent + struct dirent64 are actually the same. We require this, and
  * we want them to be interchangeable to make getdents64() work, hence verify that. */
 assert_cc(_FILE_OFFSET_BITS == 64);
+#if HAVE_STRUCT_DIRENT64
 assert_cc(sizeof(struct dirent) == sizeof(struct dirent64));
 assert_cc(offsetof(struct dirent, d_ino) == offsetof(struct dirent64, d_ino));
 assert_cc(sizeof_field(struct dirent, d_ino) == sizeof_field(struct dirent64, d_ino));
@@ -47,6 +48,7 @@ assert_cc(offsetof(struct dirent, d_type) == offsetof(struct dirent64, d_type));
 assert_cc(sizeof_field(struct dirent, d_type) == sizeof_field(struct dirent64, d_type));
 assert_cc(offsetof(struct dirent, d_name) == offsetof(struct dirent64, d_name));
 assert_cc(sizeof_field(struct dirent, d_name) == sizeof_field(struct dirent64, d_name));
+#endif
 
 #define FOREACH_DIRENT_IN_BUFFER(de, buf, sz)                           \
         for (void *_end = (uint8_t*) ({ (de) = (buf); }) + (sz);        \