From: Ralph Sennhauser Date: Thu, 12 Jan 2017 20:12:40 +0000 (-0600) Subject: xfs_io: fix building with musl X-Git-Tag: v4.10.0-rc1~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b86cff74f1e48a1227aabf40f7da5a12a4c9ad5;p=thirdparty%2Fxfsprogs-dev.git xfs_io: fix building with musl 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 Reviewed--by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/io/readdir.c b/io/readdir.c index 151b72eb4..2b56dc827 100644 --- a/io/readdir.c +++ b/io/readdir.c @@ -24,6 +24,10 @@ #include #include +#ifndef _DIRENT_HAVE_D_RECLEN +#include +#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++;