summaryrefslogtreecommitdiff
path: root/lib/sqfs/dir_reader/internal.h
blob: cd20b696da0f09d8fad05d42779043023b0677a5 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
 * internal.h
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#ifndef DIR_READER_INTERNAL_H
#define DIR_READER_INTERNAL_H

#include "config.h"

#include "sqfs/meta_reader.h"
#include "sqfs/dir_reader.h"
#include "sqfs/compressor.h"
#include "sqfs/id_table.h"
#include "sqfs/super.h"
#include "sqfs/inode.h"
#include "sqfs/error.h"
#include "sqfs/dir.h"
#include "rbtree.h"
#include "util.h"

#include <string.h>
#include <stdlib.h>

enum {
	DIR_STATE_NONE = 0,
	DIR_STATE_OPENED = 1,
	DIR_STATE_DOT = 2,
	DIR_STATE_DOT_DOT = 3,
	DIR_STATE_ENTRIES = 4,
};

struct sqfs_dir_reader_t {
	sqfs_object_t base;

	sqfs_meta_reader_t *meta_dir;
	sqfs_meta_reader_t *meta_inode;
	const sqfs_super_t *super;

	sqfs_dir_header_t hdr;
	sqfs_u64 dir_block_start;
	size_t entries;
	size_t size;

	size_t start_size;
	sqfs_u16 dir_offset;
	sqfs_u16 inode_offset;

	sqfs_u32 flags;

	int start_state;
	int state;
	sqfs_u64 parent_ref;
	sqfs_u64 cur_ref;
	rbtree_t dcache;
};

SQFS_INTERNAL int sqfs_dir_reader_dcache_init(sqfs_dir_reader_t *rd,
					      sqfs_u32 flags);

SQFS_INTERNAL int sqfs_dir_reader_dcache_init_copy(sqfs_dir_reader_t *copy,
						   const sqfs_dir_reader_t *rd);

SQFS_INTERNAL int sqfs_dir_reader_dcache_add(sqfs_dir_reader_t *rd,
					     sqfs_u32 inode, sqfs_u64 ref);

SQFS_INTERNAL int sqfs_dir_reader_dcache_find(sqfs_dir_reader_t *rd,
					      sqfs_u32 inode, sqfs_u64 *ref);

SQFS_INTERNAL void sqfs_dir_reader_dcache_cleanup(sqfs_dir_reader_t *rd);

#endif /* DIR_READER_INTERNAL_H */