summaryrefslogtreecommitdiff
path: root/include/sqfs/meta_reader.h
blob: 6f0d1840d2fb263576845dec297cb6d4e742fd5f (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
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
 * meta_reader.h
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#ifndef SQFS_META_READER_H
#define SQFS_META_READER_H

#include "config.h"

#include "sqfs/compress.h"
#include "sqfs/data.h"

typedef struct sqfs_meta_reader_t sqfs_meta_reader_t;

#ifdef __cplusplus
extern "C" {
#endif

/* Create a meta data reader using a given compressor to extract data.
   Internally prints error message to stderr on failure.

   Start offset and limit can be specified to do bounds checking against
   a subregion of the filesystem image.
*/
sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, sqfs_compressor_t *cmp,
					    uint64_t start, uint64_t limit);

void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);

/* Returns 0 on success. Internally prints to stderr on failure */
int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
			  size_t offset);

void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m,
				   uint64_t *block_start,
				   size_t *offset);

/* Returns 0 on success. Internally prints to stderr on failure */
int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size);

#ifdef __cplusplus
}
#endif

#endif /* SQFS_META_READER_H */