xfsprogs/io: add readdir command
PATCH v3 1/1 xfsprogs/io: add readdir command
readdir reads the directory entries from an open directory from the provided offset (or 0 if not specified). On completion, readdir prints summary information regarding the number of operations and bytes transferred. Options are available to specify the starting offset, length and verbose mode to dump directory entry information.
---
v3:
- dup() file->fd and add corresponding closedir() (mark).
- add readdir section to xfs_io manpage (mark).
v2:
- Convert from getdents to readdir.
- Use configure mechanism for libc readdir() availability (zab).
- Add extra dirent fields to verbose output (zab).
configure.ac | 1 + include/builddefs.in | 1 + io/Makefile | 5 ++ io/init.c | 1 + io/io.h | 6 ++ io/readdir.c | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++ m4/package_libcdev.m4 | 15 ++++ man/man8/xfs_io.8 | 24 +++++- 8 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 io/readdir.c
configure.ac +1 -0
@@ -112,6 +112,7 @@ AC_HAVE_FIEMAP AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_BLKID_TOPO($enable_blkid) +AC_HAVE_READDIR AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([char *])
include/builddefs.in +1 -0
@@ -103,6 +103,7 @@ HAVE_FALLOCATE = @have_fallocate@ HAVE_FIEMAP = @have_fiemap@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ +HAVE_READDIR = @have_readdir@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
io/Makefile +5 -0
@@ -80,6 +80,11 @@ ifeq ($(HAVE_PREADV),yes) LCFLAGS += -DHAVE_PREADV -DHAVE_PWRITEV endif +ifeq ($(HAVE_READDIR),yes) +CFILES += readdir.c +LCFLAGS += -DHAVE_READDIR +endif + default: depend $(LTCOMMAND) include $(BUILDRULES)
io/init.c +1 -0
@@ -74,6 +74,7 @@ init_commands(void)fiemap_init ();pwrite_init ();quit_init (); +readdir_init ();resblks_init ();sendfile_init ();shutdown_init ();
io/io.h +6 -0
@@ -149,3 +149,9 @@ extern void sync_range_init(void);#else #define sync_range_init () do { } while (0)#endif + +#ifdef HAVE_READDIR +extern void readdir_init (void ); +#else +#define readdir_init () do { } while (0) +#endif
io/readdir.c new file +199 -0
199 lines not on this page · raw message
m4/package_libcdev.m4 +15 -0
@@ -170,3 +170,18 @@ AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE], AC_SUBST(have_sync_file_range) ]) +# +# Check if we have a readdir libc call +# +AC_DEFUN([AC_HAVE_READDIR], + [ AC_MSG_CHECKING([for readdir]) + AC_TRY_LINK([ +#include <dirent.h> + ], [ + readdir(0); + ], have_readdir=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_readdir) + ]) +
man/man8/xfs_io.8 +23 -1
@@ -397,6 +397,27 @@ must be specified as another open file .RB ( \-f ) or by path .RB ( \-i ). +.TP +.BI "readdir [ -v ] [ -o " offset " ] [ -l " length " ] " +Read a range of directory entries from a given offset of a directory. +.RS 1.0i +.PD 0 +.TP 0.4i +.B \-v +verbose mode - dump dirent content as defined in +.BR readdir (3) +.TP +.B \-o +specify starting +.I offset +.TP +.B \-l +specify total +.I length +to read (in bytes) +.RE +.PD +.TP .SH MEMORY MAPPED I/O COMMANDS .TP
@@ -649,4 +670,5 @@ verbose output will be printed. .BR msync (2), .BR open (2), .BR pread (2), -.BR pwrite (2). +.BR pwrite (2), +.BR readdir (3).
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 10 lines · Brian Foster
readdir reads the directory entries from an open directory from the provided offset (or 0 if not specified). On completion, readdir prints summary information regarding the number of operations and bytes transferred. Options are available to specify the starting offset, length and verbose mode to dump directory entry information.
Signed-off-by Brian Foster<[email protected]>---
Quoted 8 lines
v3:
-dup()file->fdand add correspondingclosedir()(mark).
- add readdir section toxfs_iomanpage (mark).v2:
- Convert from getdents to readdir.
- Use configure mechanism for libcreaddir()availability (zab).
- Add extra dirent fields to verbose output (zab).
Thank-you, looks great. We can get it in right away.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs