[PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
Jan Tulak
jtulak at redhat.com
Tue Aug 4 04:25:14 CDT 2015
Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory().
In dump_dirent() these checks already are used, but they were
missing in read_directory.
Signed-off-by: Jan Tulak <jtulak at redhat.com>
---
io/readdir.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/io/readdir.c b/io/readdir.c
index 20b8898..ddd62c9 100644
--- a/io/readdir.c
+++ b/io/readdir.c
@@ -104,12 +104,24 @@ read_directory(
if (!dirent)
break;
+#ifdef _DIRENT_HAVE_D_RECLEN
*total += dirent->d_reclen;
+#else
+ *total += dirent->d_namlen + sizeof(*dirent);
+#endif
count++;
if (dump) {
dump_dirent(offset, dirent);
+#ifdef _DIRENT_HAVE_D_OFF
offset = dirent->d_off;
+#else
+ /* Some platforms don't have dirent->d_off, but because it is
+ * used only for dumping the value, it should be safe to only
+ * set it to zero in such case.
+ */
+ offset = 0;
+#endif
}
}
--
2.4.3
More information about the xfs
mailing list