blob: f31b7ae2646efa7507c667b7eca71af0b457674d [file] [log] [blame]
Theodore Ts'o21c84b71997-04-29 16:15:03 +00001/*
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 Public
8 * License.
9 * %End-Header%
10 */
11
12struct ext2_block_relocate_entry {
13 blk_t new;
14 __s16 offset;
15 __u16 flags;
16 union {
17 blk_t block_ref;
18 ino_t inode_ref;
19 } owner;
20};
21
22#define RELOCATE_INODE_REF 0x0001
23
24typedef struct ext2_block_relocation_table *ext2_brel;
25
26struct ext2_block_relocation_table {
27 __u32 magic;
28 char *name;
29 blk_t current;
30 void *private;
31
32 /*
33 * Add a block relocation entry.
34 */
35 errcode_t (*put)(ext2_brel brel, blk_t old,
36 struct ext2_block_relocate_entry *ent);
37
38 /*
39 * Get a block relocation entry.
40 */
41 errcode_t (*get)(ext2_brel brel, blk_t old,
42 struct ext2_block_relocate_entry *ent);
43
44 /*
45 * Initialize for iterating over the block relocation entries.
46 */
47 errcode_t (*start_iter)(ext2_brel brel);
48
49 /*
50 * The iterator function for the inode relocation entries.
51 * Returns an inode number of 0 when out of entries.
52 */
53 errcode_t (*next)(ext2_brel brel, blk_t *old,
54 struct ext2_block_relocate_entry *ent);
55
56 /*
57 * Move the inode relocation table from one block number to
58 * another.
59 */
60 errcode_t (*move)(ext2_brel brel, blk_t old, blk_t new);
61
62 /*
63 * Remove a block relocation entry.
64 */
65 errcode_t (*delete)(ext2_brel brel, blk_t old);
66
67
68 /*
69 * Free the block relocation table.
70 */
71 errcode_t (*free)(ext2_brel brel);
72};
73
74errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block,
75 ext2_brel *brel);
76
77#define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
78#define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
79#define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
80#define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
81#define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
82#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
83#define ext2fs_brel_free(brel) ((brel)->free((brel)))
84