blob: 9fdddd40c80f185e9950e840dd28d9bd94664509 [file] [log] [blame]
Theodore Ts'o21c84b71997-04-29 16:15:03 +00001/*
2 * brel.h
Theodore Ts'oefc6f622008-08-27 23:07:54 -04003 *
Theodore Ts'o21c84b71997-04-29 16:15:03 +00004 * Copyright (C) 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
Theodore Ts'o543547a2010-05-17 21:31:56 -04007 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
Theodore Ts'o21c84b71997-04-29 16:15:03 +00009 * %End-Header%
10 */
11
12struct ext2_block_relocate_entry {
Darrick J. Wonga25487c2013-10-07 09:57:36 -040013 blk64_t new;
Theodore Ts'o21c84b71997-04-29 16:15:03 +000014 __s16 offset;
15 __u16 flags;
16 union {
Darrick J. Wonga25487c2013-10-07 09:57:36 -040017 blk64_t block_ref;
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000018 ext2_ino_t inode_ref;
Theodore Ts'o21c84b71997-04-29 16:15:03 +000019 } owner;
20};
21
Theodore Ts'o1e1da291997-06-09 14:51:29 +000022#define RELOCATE_TYPE_REF 0x0007
23#define RELOCATE_BLOCK_REF 0x0001
24#define RELOCATE_INODE_REF 0x0002
Theodore Ts'o21c84b71997-04-29 16:15:03 +000025
26typedef struct ext2_block_relocation_table *ext2_brel;
27
28struct ext2_block_relocation_table {
29 __u32 magic;
30 char *name;
Darrick J. Wonga25487c2013-10-07 09:57:36 -040031 blk64_t current;
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000032 void *priv_data;
Theodore Ts'o21c84b71997-04-29 16:15:03 +000033
34 /*
35 * Add a block relocation entry.
36 */
Darrick J. Wonga25487c2013-10-07 09:57:36 -040037 errcode_t (*put)(ext2_brel brel, blk64_t old,
Theodore Ts'o21c84b71997-04-29 16:15:03 +000038 struct ext2_block_relocate_entry *ent);
39
40 /*
41 * Get a block relocation entry.
42 */
Darrick J. Wonga25487c2013-10-07 09:57:36 -040043 errcode_t (*get)(ext2_brel brel, blk64_t old,
Theodore Ts'o21c84b71997-04-29 16:15:03 +000044 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);
Theodore Ts'oefc6f622008-08-27 23:07:54 -040050
Theodore Ts'o21c84b71997-04-29 16:15:03 +000051 /*
52 * The iterator function for the inode relocation entries.
53 * Returns an inode number of 0 when out of entries.
54 */
Darrick J. Wonga25487c2013-10-07 09:57:36 -040055 errcode_t (*next)(ext2_brel brel, blk64_t *old,
Theodore Ts'o21c84b71997-04-29 16:15:03 +000056 struct ext2_block_relocate_entry *ent);
57
58 /*
59 * Move the inode relocation table from one block number to
60 * another.
61 */
Darrick J. Wonga25487c2013-10-07 09:57:36 -040062 errcode_t (*move)(ext2_brel brel, blk64_t old, blk_t new);
Theodore Ts'o21c84b71997-04-29 16:15:03 +000063
64 /*
65 * Remove a block relocation entry.
66 */
Darrick J. Wonga25487c2013-10-07 09:57:36 -040067 errcode_t (*delete)(ext2_brel brel, blk64_t old);
Theodore Ts'o21c84b71997-04-29 16:15:03 +000068
69
70 /*
71 * Free the block relocation table.
72 */
73 errcode_t (*free)(ext2_brel brel);
74};
75
Darrick J. Wonga25487c2013-10-07 09:57:36 -040076errcode_t ext2fs_brel_memarray_create(char *name, blk64_t max_block,
Theodore Ts'o21c84b71997-04-29 16:15:03 +000077 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