1/*
2 * brel.h
3 *
4 * Copyright (C) 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
9 * %End-Header%
10 */
11
12struct ext2_block_relocate_entry {
13	blk64_t	new;
14	__s16	offset;
15	__u16	flags;
16	union {
17		blk64_t		block_ref;
18		ext2_ino_t	inode_ref;
19	} owner;
20};
21
22#define RELOCATE_TYPE_REF  0x0007
23#define RELOCATE_BLOCK_REF 0x0001
24#define RELOCATE_INODE_REF 0x0002
25
26typedef struct ext2_block_relocation_table *ext2_brel;
27
28struct ext2_block_relocation_table {
29	__u32	magic;
30	char	*name;
31	blk64_t	current;
32	void	*priv_data;
33
34	/*
35	 * Add a block relocation entry.
36	 */
37	errcode_t (*put)(ext2_brel brel, blk64_t old,
38			      struct ext2_block_relocate_entry *ent);
39
40	/*
41	 * Get a block relocation entry.
42	 */
43	errcode_t (*get)(ext2_brel brel, blk64_t old,
44			      struct ext2_block_relocate_entry *ent);
45
46	/*
47	 * Initialize for iterating over the block relocation entries.
48	 */
49	errcode_t (*start_iter)(ext2_brel brel);
50
51	/*
52	 * The iterator function for the inode relocation entries.
53	 * Returns an inode number of 0 when out of entries.
54	 */
55	errcode_t (*next)(ext2_brel brel, blk64_t *old,
56			  struct ext2_block_relocate_entry *ent);
57
58	/*
59	 * Move the inode relocation table from one block number to
60	 * another.
61	 */
62	errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
63
64	/*
65	 * Remove a block relocation entry.
66	 */
67	errcode_t (*delete)(ext2_brel brel, blk64_t old);
68
69
70	/*
71	 * Free the block relocation table.
72	 */
73	errcode_t (*free)(ext2_brel brel);
74};
75
76errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
77				    ext2_brel *brel);
78
79#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
80#define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
81#define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
82#define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
83#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
84#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
85#define ext2fs_brel_free(brel) ((brel)->free((brel)))
86
87