1*6a54128fSAndroid Build Coastguard Worker /* 2*6a54128fSAndroid Build Coastguard Worker * irel.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_inode_reference { 13*6a54128fSAndroid Build Coastguard Worker blk64_t block; 14*6a54128fSAndroid Build Coastguard Worker __u16 offset; 15*6a54128fSAndroid Build Coastguard Worker }; 16*6a54128fSAndroid Build Coastguard Worker 17*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocate_entry { 18*6a54128fSAndroid Build Coastguard Worker ext2_ino_t new; 19*6a54128fSAndroid Build Coastguard Worker ext2_ino_t orig; 20*6a54128fSAndroid Build Coastguard Worker __u16 flags; 21*6a54128fSAndroid Build Coastguard Worker __u16 max_refs; 22*6a54128fSAndroid Build Coastguard Worker }; 23*6a54128fSAndroid Build Coastguard Worker 24*6a54128fSAndroid Build Coastguard Worker typedef struct ext2_inode_relocation_table *ext2_irel; 25*6a54128fSAndroid Build Coastguard Worker 26*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocation_table { 27*6a54128fSAndroid Build Coastguard Worker __u32 magic; 28*6a54128fSAndroid Build Coastguard Worker char *name; 29*6a54128fSAndroid Build Coastguard Worker ext2_ino_t current; 30*6a54128fSAndroid Build Coastguard Worker void *priv_data; 31*6a54128fSAndroid Build Coastguard Worker 32*6a54128fSAndroid Build Coastguard Worker /* 33*6a54128fSAndroid Build Coastguard Worker * Add an inode relocation entry. 34*6a54128fSAndroid Build Coastguard Worker */ 35*6a54128fSAndroid Build Coastguard Worker errcode_t (*put)(ext2_irel irel, ext2_ino_t old, 36*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocate_entry *ent); 37*6a54128fSAndroid Build Coastguard Worker /* 38*6a54128fSAndroid Build Coastguard Worker * Get an inode relocation entry. 39*6a54128fSAndroid Build Coastguard Worker */ 40*6a54128fSAndroid Build Coastguard Worker errcode_t (*get)(ext2_irel irel, ext2_ino_t old, 41*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocate_entry *ent); 42*6a54128fSAndroid Build Coastguard Worker 43*6a54128fSAndroid Build Coastguard Worker /* 44*6a54128fSAndroid Build Coastguard Worker * Get an inode relocation entry by its original inode number 45*6a54128fSAndroid Build Coastguard Worker */ 46*6a54128fSAndroid Build Coastguard Worker errcode_t (*get_by_orig)(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old, 47*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocate_entry *ent); 48*6a54128fSAndroid Build Coastguard Worker 49*6a54128fSAndroid Build Coastguard Worker /* 50*6a54128fSAndroid Build Coastguard Worker * Initialize for iterating over the inode relocation entries. 51*6a54128fSAndroid Build Coastguard Worker */ 52*6a54128fSAndroid Build Coastguard Worker errcode_t (*start_iter)(ext2_irel irel); 53*6a54128fSAndroid Build Coastguard Worker 54*6a54128fSAndroid Build Coastguard Worker /* 55*6a54128fSAndroid Build Coastguard Worker * The iterator function for the inode relocation entries. 56*6a54128fSAndroid Build Coastguard Worker * Returns an inode number of 0 when out of entries. 57*6a54128fSAndroid Build Coastguard Worker */ 58*6a54128fSAndroid Build Coastguard Worker errcode_t (*next)(ext2_irel irel, ext2_ino_t *old, 59*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_relocate_entry *ent); 60*6a54128fSAndroid Build Coastguard Worker 61*6a54128fSAndroid Build Coastguard Worker /* 62*6a54128fSAndroid Build Coastguard Worker * Add an inode reference (i.e., note the fact that a 63*6a54128fSAndroid Build Coastguard Worker * particular block/offset contains a reference to an inode) 64*6a54128fSAndroid Build Coastguard Worker */ 65*6a54128fSAndroid Build Coastguard Worker errcode_t (*add_ref)(ext2_irel irel, ext2_ino_t ino, 66*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_reference *ref); 67*6a54128fSAndroid Build Coastguard Worker 68*6a54128fSAndroid Build Coastguard Worker /* 69*6a54128fSAndroid Build Coastguard Worker * Initialize for iterating over the inode references for a 70*6a54128fSAndroid Build Coastguard Worker * particular inode. 71*6a54128fSAndroid Build Coastguard Worker */ 72*6a54128fSAndroid Build Coastguard Worker errcode_t (*start_iter_ref)(ext2_irel irel, ext2_ino_t ino); 73*6a54128fSAndroid Build Coastguard Worker 74*6a54128fSAndroid Build Coastguard Worker /* 75*6a54128fSAndroid Build Coastguard Worker * The iterator function for the inode references for an 76*6a54128fSAndroid Build Coastguard Worker * inode. The references for only one inode can be iterator 77*6a54128fSAndroid Build Coastguard Worker * over at a time, as the iterator state is stored in ext2_irel. 78*6a54128fSAndroid Build Coastguard Worker */ 79*6a54128fSAndroid Build Coastguard Worker errcode_t (*next_ref)(ext2_irel irel, 80*6a54128fSAndroid Build Coastguard Worker struct ext2_inode_reference *ref); 81*6a54128fSAndroid Build Coastguard Worker 82*6a54128fSAndroid Build Coastguard Worker /* 83*6a54128fSAndroid Build Coastguard Worker * Move the inode relocation table from one inode number to 84*6a54128fSAndroid Build Coastguard Worker * another. Note that the inode references also must move. 85*6a54128fSAndroid Build Coastguard Worker */ 86*6a54128fSAndroid Build Coastguard Worker errcode_t (*move)(ext2_irel irel, ext2_ino_t old, ext2_ino_t new); 87*6a54128fSAndroid Build Coastguard Worker 88*6a54128fSAndroid Build Coastguard Worker /* 89*6a54128fSAndroid Build Coastguard Worker * Remove an inode relocation entry, along with all of the 90*6a54128fSAndroid Build Coastguard Worker * inode references. 91*6a54128fSAndroid Build Coastguard Worker */ 92*6a54128fSAndroid Build Coastguard Worker errcode_t (*delete)(ext2_irel irel, ext2_ino_t old); 93*6a54128fSAndroid Build Coastguard Worker 94*6a54128fSAndroid Build Coastguard Worker /* 95*6a54128fSAndroid Build Coastguard Worker * Free the inode relocation table. 96*6a54128fSAndroid Build Coastguard Worker */ 97*6a54128fSAndroid Build Coastguard Worker errcode_t (*free)(ext2_irel irel); 98*6a54128fSAndroid Build Coastguard Worker }; 99*6a54128fSAndroid Build Coastguard Worker 100*6a54128fSAndroid Build Coastguard Worker errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode, 101*6a54128fSAndroid Build Coastguard Worker ext2_irel *irel); 102*6a54128fSAndroid Build Coastguard Worker 103*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_put(irel, old, ent) ((irel)->put((irel), old, ent)) 104*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_get(irel, old, ent) ((irel)->get((irel), old, ent)) 105*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_get_by_orig(irel, orig, old, ent) \ 106*6a54128fSAndroid Build Coastguard Worker ((irel)->get_by_orig((irel), orig, old, ent)) 107*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_start_iter(irel) ((irel)->start_iter((irel))) 108*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_next(irel, old, ent) ((irel)->next((irel), old, ent)) 109*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_add_ref(irel, ino, ref) ((irel)->add_ref((irel), ino, ref)) 110*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_start_iter_ref(irel, ino) ((irel)->start_iter_ref((irel), ino)) 111*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_next_ref(irel, ref) ((irel)->next_ref((irel), ref)) 112*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_move(irel, old, new) ((irel)->move((irel), old, new)) 113*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_delete(irel, old) ((irel)->delete((irel), old)) 114*6a54128fSAndroid Build Coastguard Worker #define ext2fs_irel_free(irel) ((irel)->free((irel))) 115