From: Ralph Sennhauser <ralph.sennhauser@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Subject: [PATCH] xfs_io: fix building with musl
Date: Fri, 9 Sep 2016 15:32:22 +0200 [thread overview]
Message-ID: <1473427942-10726-1-git-send-email-ralph.sennhauser@gmail.com> (raw)
In-Reply-To: <1473241376-10922-1-git-send-email-ralph.sennhauser@gmail.com>
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>
---
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
next prev parent reply other threads:[~2016-09-09 13:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1473241376-10922-1-git-send-email-ralph.sennhauser@gmail.com>
2016-09-07 22:27 ` [BUG] xfsprogs-4.7.0: issues cross-compiling for musl Dave Chinner
2016-09-07 22:40 ` Eric Sandeen
2016-09-08 8:41 ` Ralph Sennhauser
2016-09-08 12:13 ` Eric Sandeen
2016-09-08 13:22 ` Ralph Sennhauser
2016-09-08 8:35 ` Ralph Sennhauser
2016-09-09 13:32 ` Ralph Sennhauser [this message]
2016-09-09 13:59 ` [PATCH] xfs_io: fix building with musl Eric Sandeen
2016-09-09 17:07 ` Ralph Sennhauser
2016-09-10 7:37 ` [RFC] libxfs: cross-compile fixes Ralph Sennhauser
2016-09-19 5:50 ` Dave Chinner
2016-09-19 7:32 ` Ralph Sennhauser
2017-01-15 20:32 ` Eric Sandeen
2017-01-16 13:45 ` Ralph Sennhauser
2017-01-16 14:42 ` Eric Sandeen
2017-01-16 14:50 ` Ralph Sennhauser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473427942-10726-1-git-send-email-ralph.sennhauser@gmail.com \
--to=ralph.sennhauser@gmail.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).