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

#include "config.h"

#include "sqfs/meta_reader.h"

#include <stdint.h>

#define SQFS_MAX_DIR_ENT 256

typedef struct {
	uint32_t count;
	uint32_t start_block;
	uint32_t inode_number;
} sqfs_dir_header_t;

typedef struct {
	uint16_t offset;
	int16_t inode_diff;
	uint16_t type;
	uint16_t size;
	uint8_t name[];
} sqfs_dir_entry_t;

typedef struct {
	uint32_t index;
	uint32_t start_block;
	uint32_t size;
	uint8_t name[];
} sqfs_dir_index_t;

/* Returns 0 on success. Internally prints to stderr on failure */
int meta_reader_read_dir_header(meta_reader_t *m, sqfs_dir_header_t *hdr);

/* Entry can be freed with a single free() call.
   The function internally prints to stderr on failure */
sqfs_dir_entry_t *meta_reader_read_dir_ent(meta_reader_t *m);

#endif /* SQFS_DIR_H */