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