3
0

brel.h 2.1 KB

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