diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-05 17:38:08 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-08-05 17:45:59 +0200 |
commit | 88f75857702bcc6a2a423570912140c125ec518a (patch) | |
tree | a1ec54e2520e076395208872d36606f917c8ca34 /include/highlevel.h | |
parent | 3a340b12eb9b7ed86a47391345cb836fa662b2d9 (diff) |
cleanup: unify all the code that reads squashfs images
This commit creates a new data structure called 'sqfs_reader_t' that
takes care of all the repetetive tasks like opening the file, reading
the super block, creating the compressor, deserializing an fstree and
creating a data reader.
This in turn makes it possible to remove all the duplicate code from
rdsquashfs and sqfs2tar.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/highlevel.h')
-rw-r--r-- | include/highlevel.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/highlevel.h b/include/highlevel.h index e3afbd7..f8c5bfb 100644 --- a/include/highlevel.h +++ b/include/highlevel.h @@ -9,6 +9,7 @@ #include "config.h" +#include "data_reader.h" #include "squashfs.h" #include "compress.h" #include "id_table.h" @@ -17,6 +18,14 @@ #include <stdint.h> #include <stddef.h> +typedef struct { + compressor_t *cmp; + data_reader_t *data; + sqfs_super_t super; + fstree_t fs; + int sqfsfd; +} sqfs_reader_t; + enum RDTREE_FLAGS { RDTREE_NO_DEVICES = 0x01, RDTREE_NO_SOCKETS = 0x02, @@ -96,4 +105,14 @@ int write_export_table(int outfd, fstree_t *fs, sqfs_super_t *super, /* Print out fancy statistics for squashfs packing tools */ void sqfs_print_statistics(fstree_t *fs, sqfs_super_t *super); +/* Open a squashfs file, extract all the information we may need and + construct datastructures we need to access its contents. + Returns 0 on success. Prints error messages to stderr on failure. +*/ +int sqfs_reader_open(sqfs_reader_t *rd, const char *filename, + int rdtree_flags); + +/* Cleanup after a successfull sqfs_reader_open */ +void sqfs_reader_close(sqfs_reader_t *rd); + #endif /* HIGHLEVEL_H */ |