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>
#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)
#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++;