diff options
Diffstat (limited to 'unpack')
-rw-r--r-- | unpack/options.c | 2 | ||||
-rw-r--r-- | unpack/rdsquashfs.c | 20 |
2 files changed, 8 insertions, 14 deletions
diff --git a/unpack/options.c b/unpack/options.c index ccfe7c8..84c17cf 100644 --- a/unpack/options.c +++ b/unpack/options.c @@ -124,6 +124,8 @@ void process_command_line(options_t *opt, int argc, char **argv) break; case 'd': opt->op = OP_DESCRIBE; + free(opt->cmdpath); + opt->cmdpath = NULL; break; case 'l': opt->op = OP_LS; diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c index 27a0cf5..125a841 100644 --- a/unpack/rdsquashfs.c +++ b/unpack/rdsquashfs.c @@ -85,23 +85,21 @@ int main(int argc, char **argv) if (deserialize_fstree(&fs, &super, cmp, sqfsfd, opt.rdtree_flags)) goto out_cmp; - switch (opt.op) { - case OP_LS: + if (opt.cmdpath != NULL) { n = find_node(fs.root, opt.cmdpath); if (n == NULL) { perror(opt.cmdpath); goto out_fs; } + } else { + n = fs.root; + } + switch (opt.op) { + case OP_LS: list_files(n); break; case OP_CAT: - n = find_node(fs.root, opt.cmdpath); - if (n == NULL) { - perror(opt.cmdpath); - goto out_fs; - } - if (!S_ISREG(n->mode)) { fprintf(stderr, "/%s: not a regular file\n", opt.cmdpath); @@ -116,12 +114,6 @@ int main(int argc, char **argv) goto out_fs; break; case OP_UNPACK: - n = find_node(fs.root, opt.cmdpath); - if (n == NULL) { - perror(opt.cmdpath); - goto out_fs; - } - data = data_reader_create(sqfsfd, &super, cmp); if (data == NULL) goto out_fs; |