Skip to contentSkip to conversation

erofs-utils: dump: convert readdir to use erofs_iterate_dir()

PATCH New Gao Xiang 1 participant 1 message Dec 16, 2021 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: dump: convert readdir to use erofs_iterate_dir()

No need to open code after erofs_iterate_dir() is finalized in liberofs.

Note that `erofs_get_pathname' isn't touched in this commit.

---
 configure.ac           |   5 ++
 dump/main.c            | 182 +++++++++++++++++------------------------
 lib/liberofs_private.h |  12 +++
 3 files changed, 93 insertions(+), 106 deletions(-)
configure.ac +5 -0
index 6fdb0e4ce63c..a5de291c69d4 100644
@@ -167,6 +167,11 @@ AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
    #define _LARGEFILE64_SOURCE
    #include <unistd.h>])
 
+AC_CHECK_DECL(memrchr,[AC_DEFINE(HAVE_MEMRCHR, 1,
+  [Define to 1 if memrchr declared in string.h])],,
+  [#define _GNU_SOURCE
+   #include <string.h>])
+
 # Checks for library functions.
 AC_CHECK_FUNCS(m4_flatten([
 	backtrace
dump/main.c +76 -106

232 lines not on this page · raw message

lib/liberofs_private.h +12 -0
index c2312e8e7a31..0eeca3c1d601 100644
@@ -11,3 +11,15 @@
 #include <private/canned_fs_config.h>
 #include <private/fs_config.h>
 #endif
+
+#ifndef HAVE_MEMRCHR
+static inline void *memrchr(const void *s, int c, size_t n)
+{
+	const unsigned char *p = (const unsigned char *)s;
+
+	for (p += n; n > 0; n--)
+		if (*--p == c)
+			return (void*)p;
+	return NULL;
+}
+#endif
Signature · 1 line
2.20.1