summaryrefslogtreecommitdiff
path: root/unpack/rdsquashfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-11 18:15:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-11 18:15:10 +0200
commit842c5ec8e5c05e0d9c245882f13ca0a6b19825f5 (patch)
treed04f058efdc486bc25890b8f4d3dea6ea38c5764 /unpack/rdsquashfs.c
parent8fa122a59f61878bafa43ea45d9ea988f3a70998 (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.c20
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;