summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Crane <arc@aaroncrane.co.uk>2014-08-03 21:54:14 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-08-04 18:58:23 -0400
commitb6edbf6b900d2dcc1fb0365c173cada8fa917db3 (patch)
tree32980604ef1ef2d14d9af0ea348fdf43e07116cf
parent850fe1aca7927da19ce3606487b91be48953df03 (diff)
downloade2fsprogs-b6edbf6b900d2dcc1fb0365c173cada8fa917db3.tar.gz
debugfs: teach rdump to take multiple source arguments
[ modified to update man page by tytso ] Signed-off-by: Aaron Crane <arc@aaroncrane.co.uk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--debugfs/debugfs.8.in8
-rw-r--r--debugfs/dump.c38
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",
- "<directory> <native directory>", 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",
+ "<directory>... <native directory>", 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)