summaryrefslogtreecommitdiff
path: root/lib/ntdb/test/layout.h
blob: b4f6a960eb9639437dc6c0519b8975703c6fb8b9 (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
74
75
76
77
78
79
#ifndef NTDB_TEST_LAYOUT_H
#define NTDB_TEST_LAYOUT_H
#include "private.h"

struct ntdb_layout *new_ntdb_layout(void);
void ntdb_layout_add_freetable(struct ntdb_layout *layout);
void ntdb_layout_add_free(struct ntdb_layout *layout, ntdb_len_t len,
			 unsigned ftable);
void ntdb_layout_add_used(struct ntdb_layout *layout,
			 NTDB_DATA key, NTDB_DATA data,
			 ntdb_len_t extra);
void ntdb_layout_add_capability(struct ntdb_layout *layout,
			       uint64_t type,
			       bool write_breaks,
			       bool check_breaks,
			       bool open_breaks,
			       ntdb_len_t extra);

#if 0 /* FIXME: Allow allocation of subtables */
void ntdb_layout_add_hashtable(struct ntdb_layout *layout,
			      int htable_parent, /* -1 == toplevel */
			      unsigned int bucket,
			      ntdb_len_t extra);
#endif
/* freefn is needed if we're using failtest_free. */
struct ntdb_context *ntdb_layout_get(struct ntdb_layout *layout,
				   void (*freefn)(void *),
				   union ntdb_attribute *attr);
void ntdb_layout_write(struct ntdb_layout *layout, void (*freefn)(void *),
		       union ntdb_attribute *attr, const char *filename);

void ntdb_layout_free(struct ntdb_layout *layout);

enum layout_type {
	FREETABLE, FREE, DATA, CAPABILITY
};

/* Shared by all union members. */
struct tle_base {
	enum layout_type type;
	ntdb_off_t off;
};

struct tle_freetable {
	struct tle_base base;
};

struct tle_free {
	struct tle_base base;
	ntdb_len_t len;
	unsigned ftable_num;
};

struct tle_used {
	struct tle_base base;
	NTDB_DATA key;
	NTDB_DATA data;
	ntdb_len_t extra;
};

struct tle_capability {
	struct tle_base base;
	uint64_t type;
	ntdb_len_t extra;
};

union ntdb_layout_elem {
	struct tle_base base;
	struct tle_freetable ftable;
	struct tle_free free;
	struct tle_used used;
	struct tle_capability capability;
};

struct ntdb_layout {
	unsigned int num_elems;
	union ntdb_layout_elem *elem;
};
#endif /* NTDB_TEST_LAYOUT_H */