3
0

irel.h 3.3 KB

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