brel.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  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. struct ext2_block_relocate_entry {
  12. blk_t new;
  13. __s16 offset;
  14. __u16 flags;
  15. union {
  16. blk_t block_ref;
  17. ext2_ino_t inode_ref;
  18. } owner;
  19. };
  20. #define RELOCATE_TYPE_REF 0x0007
  21. #define RELOCATE_BLOCK_REF 0x0001
  22. #define RELOCATE_INODE_REF 0x0002
  23. typedef struct ext2_block_relocation_table *ext2_brel;
  24. struct ext2_block_relocation_table {
  25. __u32 magic;
  26. char *name;
  27. blk_t current;
  28. void *priv_data;
  29. /*
  30. * Add a block relocation entry.
  31. */
  32. errcode_t (*put)(ext2_brel brel, blk_t old,
  33. struct ext2_block_relocate_entry *ent);
  34. /*
  35. * Get a block relocation entry.
  36. */
  37. errcode_t (*get)(ext2_brel brel, blk_t old,
  38. struct ext2_block_relocate_entry *ent);
  39. /*
  40. * Initialize for iterating over the block relocation entries.
  41. */
  42. errcode_t (*start_iter)(ext2_brel brel);
  43. /*
  44. * The iterator function for the inode relocation entries.
  45. * Returns an inode number of 0 when out of entries.
  46. */
  47. errcode_t (*next)(ext2_brel brel, blk_t *old,
  48. struct ext2_block_relocate_entry *ent);
  49. /*
  50. * Move the inode relocation table from one block number to
  51. * another.
  52. */
  53. errcode_t (*move)(ext2_brel brel, blk_t old, blk_t new);
  54. /*
  55. * Remove a block relocation entry.
  56. */
  57. errcode_t (*delete)(ext2_brel brel, blk_t old);
  58. /*
  59. * Free the block relocation table.
  60. */
  61. errcode_t (*free)(ext2_brel brel);
  62. };
  63. errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block,
  64. ext2_brel *brel);
  65. #define ext2fs_brel_put(brel, old, ent) ((brel)->put((brel), old, ent))
  66. #define ext2fs_brel_get(brel, old, ent) ((brel)->get((brel), old, ent))
  67. #define ext2fs_brel_start_iter(brel) ((brel)->start_iter((brel)))
  68. #define ext2fs_brel_next(brel, old, ent) ((brel)->next((brel), old, ent))
  69. #define ext2fs_brel_move(brel, old, new) ((brel)->move((brel), old, new))
  70. #define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
  71. #define ext2fs_brel_free(brel) ((brel)->free((brel)))