summaryrefslogtreecommitdiff
path: root/unpack/rdsquashfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 22:22:12 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-04 22:22:48 +0200
commitabb31e7327e50cf2874ae9095eb147ed753862a3 (patch)
tree7651bc9ba2b936568bc3da75f9041e3c1d1e6430 /unpack/rdsquashfs.c
parentb6f55d3c8fe387c3dc9b82821d49fcb56fa83483 (diff)
rdsquashfs: add ability to unpack only a sub tree of the file system
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/rdsquashfs.c')
-rw-r--r--unpack/rdsquashfs.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c
index ec14e0e..4b3a573 100644
--- a/unpack/rdsquashfs.c
+++ b/unpack/rdsquashfs.c
@@ -12,6 +12,7 @@ static struct option long_opts[] = {
{ "list", required_argument, NULL, 'l' },
{ "cat", required_argument, NULL, 'c' },
{ "unpack-root", required_argument, NULL, 'u' },
+ { "unpack-path", required_argument, NULL, 'p' },
{ "no-dev", no_argument, NULL, 'D' },
{ "no-sock", no_argument, NULL, 'S' },
{ "no-fifo", no_argument, NULL, 'F' },
@@ -23,7 +24,7 @@ static struct option long_opts[] = {
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "l:c:u:DSFLCOEhV";
+static const char *short_opts = "l:c:u:p:DSFLCOEhV";
static const char *help_string =
"Usage: %s [OPTIONS] <squashfs-file>\n"
@@ -37,6 +38,8 @@ static const char *help_string =
" image, dump its contents to stdout.\n"
" --unpack-root <path> Unpack the contents of the filesystem into the\n"
" specified path.\n"
+" --unpack-path <path> If specified, unpack this sub directory from the\n"
+" image instead of the filesystem root.\n"
" --no-dev, -D Do not unpack device special files.\n"
" --no-sock, -S Do not unpack socket files.\n"
" --no-fifo, -F Do not unpack named pipes.\n"
@@ -157,6 +160,9 @@ int main(int argc, char **argv)
op = OP_UNPACK;
unpack_root = optarg;
break;
+ case 'p':
+ cmdpath = get_path(cmdpath, optarg);
+ break;
case 'h':
printf(help_string, __progname);
status = EXIT_SUCCESS;
@@ -255,6 +261,16 @@ int main(int argc, char **argv)
}
break;
case OP_UNPACK:
+ if (cmdpath == NULL) {
+ n = fs.root;
+ } else {
+ n = find_node(fs.root, cmdpath);
+ if (n == NULL) {
+ perror(cmdpath);
+ goto out_fs;
+ }
+ }
+
if (super.fragment_entry_count > 0 &&
super.fragment_table_start < super.bytes_used &&
!(super.flags & SQFS_FLAG_NO_FRAGMENTS)) {
@@ -263,7 +279,7 @@ int main(int argc, char **argv)
goto out_fs;
}
- if (restore_fstree(unpack_root, fs.root, cmp, super.block_size,
+ if (restore_fstree(unpack_root, n, cmp, super.block_size,
frag, fd, unpack_flags)) {
goto out_fs;
}