irel.h 3.3 KB

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