[PATCH] xfs_io: fix building with musl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---

With ustat.h issue resolved in 4.8.0-rc1 this is the only musl related
one left.

An alternative could be some autoconf magic [1] or waiting for a long
time for musl to add _DIRENT_HAVE_D_RECLEN [2] and for it to propagate
to distributions.

[1] http://oss.sgi.com/archives/xfs/2016-01/msg00388.html
[2] http://www.openwall.com/lists/musl/2016/01/15/9

---
 io/readdir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/io/readdir.c b/io/readdir.c
index 151b72e..2b56dc8 100644
--- a/io/readdir.c
+++ b/io/readdir.c
@@ -24,6 +24,10 @@
 #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++;
 
-- 
2.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux