summaryrefslogtreecommitdiff
path: root/fs/squashfs/sqfs.c
diff options
context:
space:
mode:
authorJoao Marcos Costa <joaomarcos.costa@bootlin.com>2020-08-18 17:17:21 +0200
committerTom Rini <trini@konsulko.com>2020-08-24 14:11:31 -0400
commit10f7cf5f12a8721d6c985d4de11dac4d19e0e47e (patch)
tree970ab35116ee4f6882c4b1cc499b71175ee4ea24 /fs/squashfs/sqfs.c
parent4a1f0b80adfc9465e8a3efcb884d397e5ab7f07f (diff)
fs/squashfs: Add init and clean-up functions to decompression
Add sqfs_decompressor_init() and sqfs_decompressor_cleanup(). These functions are called respectively in sqfs_probe() and sqfs_close(). For now, only ZSTD requires an initialization logic. ZSTD support will be added in a follow-up commit. Move squashfs_ctxt definition to sqfs_filesystem.h. This structure is passed to sqfs_decompressor_init() and sqfs_decompressor_cleanup(), so it can no longer be local to sqfs.c. Signed-off-by: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
Diffstat (limited to 'fs/squashfs/sqfs.c')
-rw-r--r--fs/squashfs/sqfs.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 340e5ebdb9..598b42cd34 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -23,12 +23,6 @@
#include "sqfs_filesystem.h"
#include "sqfs_utils.h"
-struct squashfs_ctxt {
- struct disk_partition cur_part_info;
- struct blk_desc *cur_dev;
- struct squashfs_super_block *sblk;
-};
-
static struct squashfs_ctxt ctxt;
static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf)
@@ -1023,6 +1017,14 @@ int sqfs_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition
ctxt.sblk = sblk;
+ ret = sqfs_decompressor_init(&ctxt);
+
+ if (ret) {
+ ctxt.cur_dev = NULL;
+ free(ctxt.sblk);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -1525,6 +1527,7 @@ void sqfs_close(void)
{
free(ctxt.sblk);
ctxt.cur_dev = NULL;
+ sqfs_decompressor_cleanup(&ctxt);
}
void sqfs_closedir(struct fs_dir_stream *dirs)