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