From b6edbf6b900d2dcc1fb0365c173cada8fa917db3 Mon Sep 17 00:00:00 2001 From: Aaron Crane Date: Sun, 3 Aug 2014 21:54:14 -0400 Subject: debugfs: teach rdump to take multiple source arguments [ modified to update man page by tytso ] Signed-off-by: Aaron Crane Signed-off-by: Theodore Ts'o --- debugfs/debugfs.8.in | 8 +++++--- debugfs/dump.c | 38 ++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in index 9a125f6c..bae14db0 100644 --- a/debugfs/debugfs.8.in +++ b/debugfs/debugfs.8.in @@ -503,12 +503,14 @@ Print the current working directory. Quit .B debugfs .TP -.BI rdump " directory destination" +.BI rdump " directory[...] destination" Recursively dump -.I directory +.IR directory , +or multiple +.IR directories , and all its contents (including regular files, symbolic links, and other directories) into the named -.I destination +.IR destination , which should be an existing directory on the native filesystem. .TP .BI rm " pathname" diff --git a/debugfs/dump.c b/debugfs/dump.c index 0fa14b64..8d978864 100644 --- a/debugfs/dump.c +++ b/debugfs/dump.c @@ -326,18 +326,12 @@ static int rdump_dirent(struct ext2_dir_entry *dirent, void do_rdump(int argc, char **argv) { - ext2_ino_t ino; - struct ext2_inode inode; struct stat st; - char *arg, *dest_dir, *basename; - - if (common_args_process(argc, argv, 3, 3, "rdump", - " ", 0)) - return; + char *dest_dir; + int i; - arg = argv[1]; - ino = string_to_inode(arg); - if (!ino) + if (common_args_process(argc, argv, 3, INT_MAX, "rdump", + "... ", 0)) return; /* Pull out last argument */ @@ -354,16 +348,24 @@ void do_rdump(int argc, char **argv) return; } - if (debugfs_read_inode(ino, &inode, arg)) - return; + for (i = 1; i < argc; i++) { + char *arg = argv[i], *basename; + struct ext2_inode inode; + ext2_ino_t ino = string_to_inode(arg); + if (!ino) + continue; - basename = strrchr(arg, '/'); - if (basename) - basename++; - else - basename = arg; + if (debugfs_read_inode(ino, &inode, arg)) + continue; - rdump_inode(ino, &inode, basename, dest_dir); + basename = strrchr(arg, '/'); + if (basename) + basename++; + else + basename = arg; + + rdump_inode(ino, &inode, basename, dest_dir); + } } void do_cat(int argc, char **argv) -- cgit v1.2.1