aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 17:51:33 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 17:51:33 +0100
commit1a4af498b497bfe1acb40d8aff0c65d9b22b3aa5 (patch)
treebe88b633cf30bc168cc22afedec57114bc3d410d /extras
parent84bd62267760fd02db895e21c5c2c8bf20162342 (diff)
Add a helper function to unpack directory index entries
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'extras')
-rw-r--r--extras/browse.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/extras/browse.c b/extras/browse.c
index 1179b33..1d6417f 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -3,6 +3,7 @@
#include "sqfs/id_table.h"
#include "sqfs/inode.h"
#include "sqfs/super.h"
+#include "sqfs/error.h"
#include "sqfs/dir.h"
#include "sqfs/io.h"
@@ -358,16 +359,22 @@ static void stat_cmd(const char *filename)
if (inode->data.dir_ext.size == 0)
break;
- idx = (sqfs_dir_index_t *)inode->extra;
+ for (i = 0; ; ++i) {
+ ret = sqfs_inode_unpack_dir_index_entry(inode, &idx, i);
+ if (ret == SQFS_ERROR_OUT_OF_BOUNDS)
+ break;
+ if (ret < 0) {
+ printf("Error reading index, error code %d\n",
+ ret);
+ break;
+ }
- for (i = 0; i < inode->data.dir_ext.inodex_count; ++i) {
printf("\tIndex: %u\n", idx->index);
printf("\tStart block: %u\n", idx->start_block);
printf("\tSize: %u\n", idx->size + 1);
printf("\tEntry: %.*s\n\n", idx->size + 1, idx->name);
- idx = (sqfs_dir_index_t *)
- ((char *)idx + sizeof(*idx) + idx->size + 1);
+ free(idx);
}
break;
}