diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-11 18:15:10 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-11 18:15:10 +0200 |
commit | 842c5ec8e5c05e0d9c245882f13ca0a6b19825f5 (patch) | |
tree | d04f058efdc486bc25890b8f4d3dea6ea38c5764 /unpack/rdsquashfs.c | |
parent | 8fa122a59f61878bafa43ea45d9ea988f3a70998 (diff) |
cleanup: pull out common code path
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/rdsquashfs.c')
-rw-r--r-- | unpack/rdsquashfs.c | 20 |
1 files changed, 6 insertions, 14 deletions
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; |