summaryrefslogtreecommitdiff
path: root/unpack/rdsquashfs.h
blob: a9d5bdf48e20f4f3594b86258149e6646fa5d9cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef RDSQUASHFS_H
#define RDSQUASHFS_H

#include "meta_reader.h"
#include "frag_reader.h"
#include "squashfs.h"
#include "compress.h"
#include "id_table.h"
#include "fstree.h"
#include "config.h"
#include "util.h"

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>

enum UNPACK_FLAGS {
	UNPACK_NO_DEVICES = 0x01,
	UNPACK_NO_SOCKETS = 0x02,
	UNPACK_NO_FIFO = 0x04,
	UNPACK_NO_SLINKS = 0x08,
	UNPACK_NO_EMPTY = 0x10,
	UNPACK_CHMOD = 0x20,
	UNPACK_CHOWN = 0x40,
	UNPACK_QUIET = 0x80,
};

typedef struct {
	compressor_t *cmp;
	size_t block_size;
	frag_reader_t *frag;
	int sqfsfd;
	int flags;

	void *buffer;
	void *scratch;
} unsqfs_info_t;

tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode,
				  const id_table_t *idtbl,
				  const char *name,
				  size_t block_size);

int read_fstree(fstree_t *out, sqfs_super_t *super, unsqfs_info_t *info);

void list_files(tree_node_t *node);

int extract_file(file_info_t *fi, unsqfs_info_t *info, int outfd);

int restore_fstree(const char *rootdir, tree_node_t *root,
		   unsqfs_info_t *info);

#endif /* RDSQUASHFS_H */