]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_io: fix building with musl
authorRalph Sennhauser <ralph.sennhauser@gmail.com>
Thu, 12 Jan 2017 20:12:40 +0000 (14:12 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 12 Jan 2017 20:12:40 +0000 (14:12 -0600)
The fallback in case the libc doesn't have or doesn't advertise the
existence of d_reclen in struct dirent uses d_namlen. Musl neither
advertises d_reclen nor does it have a d_namlen member.

Calculate the value for d_namlen from d_name in the fallback path.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Reviewed--by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/readdir.c

index 151b72eb4512a5a28546b067ff47fe72aa8184c5..2b56dc827fce6f6152f398b1f03b22c2d76ec8a3 100644 (file)
 #include <sys/types.h>
 #include <dirent.h>
 
+#ifndef _DIRENT_HAVE_D_RECLEN
+#include <string.h>
+#endif
+
 static struct cmdinfo readdir_cmd;
 
 const char *d_type_str(unsigned int type)
@@ -106,7 +110,7 @@ read_directory(
 #ifdef _DIRENT_HAVE_D_RECLEN
                *total += dirent->d_reclen;
 #else
-               *total += dirent->d_namlen + sizeof(*dirent);
+               *total += strlen(dirent->d_name) + sizeof(*dirent);
 #endif
                count++;