xfs_dir2.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_DIR2_H__
  19. #define __XFS_DIR2_H__
  20. struct xfs_bmap_free;
  21. struct xfs_da_args;
  22. struct xfs_inode;
  23. struct xfs_mount;
  24. struct xfs_trans;
  25. struct xfs_dir2_sf_hdr;
  26. struct xfs_dir2_sf_entry;
  27. struct xfs_dir2_data_hdr;
  28. struct xfs_dir2_data_entry;
  29. struct xfs_dir2_data_unused;
  30. extern struct xfs_name xfs_name_dotdot;
  31. /*
  32. * directory operations vector for encode/decode routines
  33. */
  34. struct xfs_dir_ops {
  35. int (*sf_entsize)(struct xfs_dir2_sf_hdr *hdr, int len);
  36. struct xfs_dir2_sf_entry *
  37. (*sf_nextentry)(struct xfs_dir2_sf_hdr *hdr,
  38. struct xfs_dir2_sf_entry *sfep);
  39. __uint8_t (*sf_get_ftype)(struct xfs_dir2_sf_entry *sfep);
  40. void (*sf_put_ftype)(struct xfs_dir2_sf_entry *sfep,
  41. __uint8_t ftype);
  42. xfs_ino_t (*sf_get_ino)(struct xfs_dir2_sf_hdr *hdr,
  43. struct xfs_dir2_sf_entry *sfep);
  44. void (*sf_put_ino)(struct xfs_dir2_sf_hdr *hdr,
  45. struct xfs_dir2_sf_entry *sfep,
  46. xfs_ino_t ino);
  47. xfs_ino_t (*sf_get_parent_ino)(struct xfs_dir2_sf_hdr *hdr);
  48. void (*sf_put_parent_ino)(struct xfs_dir2_sf_hdr *hdr,
  49. xfs_ino_t ino);
  50. int (*data_entsize)(int len);
  51. __uint8_t (*data_get_ftype)(struct xfs_dir2_data_entry *dep);
  52. void (*data_put_ftype)(struct xfs_dir2_data_entry *dep,
  53. __uint8_t ftype);
  54. __be16 * (*data_entry_tag_p)(struct xfs_dir2_data_entry *dep);
  55. struct xfs_dir2_data_free *
  56. (*data_bestfree_p)(struct xfs_dir2_data_hdr *hdr);
  57. xfs_dir2_data_aoff_t data_dot_offset;
  58. xfs_dir2_data_aoff_t data_dotdot_offset;
  59. xfs_dir2_data_aoff_t data_first_offset;
  60. size_t data_entry_offset;
  61. struct xfs_dir2_data_entry *
  62. (*data_dot_entry_p)(struct xfs_dir2_data_hdr *hdr);
  63. struct xfs_dir2_data_entry *
  64. (*data_dotdot_entry_p)(struct xfs_dir2_data_hdr *hdr);
  65. struct xfs_dir2_data_entry *
  66. (*data_first_entry_p)(struct xfs_dir2_data_hdr *hdr);
  67. struct xfs_dir2_data_entry *
  68. (*data_entry_p)(struct xfs_dir2_data_hdr *hdr);
  69. struct xfs_dir2_data_unused *
  70. (*data_unused_p)(struct xfs_dir2_data_hdr *hdr);
  71. int leaf_hdr_size;
  72. void (*leaf_hdr_to_disk)(struct xfs_dir2_leaf *to,
  73. struct xfs_dir3_icleaf_hdr *from);
  74. void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to,
  75. struct xfs_dir2_leaf *from);
  76. int (*leaf_max_ents)(struct xfs_mount *mp);
  77. struct xfs_dir2_leaf_entry *
  78. (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
  79. int node_hdr_size;
  80. void (*node_hdr_to_disk)(struct xfs_da_intnode *to,
  81. struct xfs_da3_icnode_hdr *from);
  82. void (*node_hdr_from_disk)(struct xfs_da3_icnode_hdr *to,
  83. struct xfs_da_intnode *from);
  84. struct xfs_da_node_entry *
  85. (*node_tree_p)(struct xfs_da_intnode *dap);
  86. int free_hdr_size;
  87. void (*free_hdr_to_disk)(struct xfs_dir2_free *to,
  88. struct xfs_dir3_icfree_hdr *from);
  89. void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to,
  90. struct xfs_dir2_free *from);
  91. int (*free_max_bests)(struct xfs_mount *mp);
  92. __be16 * (*free_bests_p)(struct xfs_dir2_free *free);
  93. xfs_dir2_db_t (*db_to_fdb)(struct xfs_mount *mp, xfs_dir2_db_t db);
  94. int (*db_to_fdindex)(struct xfs_mount *mp, xfs_dir2_db_t db);
  95. };
  96. extern const struct xfs_dir_ops *
  97. xfs_dir_get_ops(struct xfs_mount *mp, struct xfs_inode *dp);
  98. extern const struct xfs_dir_ops *
  99. xfs_nondir_get_ops(struct xfs_mount *mp, struct xfs_inode *dp);
  100. /*
  101. * Generic directory interface routines
  102. */
  103. extern void xfs_dir_startup(void);
  104. extern void xfs_dir_mount(struct xfs_mount *mp);
  105. extern int xfs_dir_isempty(struct xfs_inode *dp);
  106. extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
  107. struct xfs_inode *pdp);
  108. extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
  109. struct xfs_name *name, xfs_ino_t inum,
  110. xfs_fsblock_t *first,
  111. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  112. extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
  113. struct xfs_name *name, xfs_ino_t *inum,
  114. struct xfs_name *ci_name);
  115. extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
  116. struct xfs_name *name, xfs_ino_t ino,
  117. xfs_fsblock_t *first,
  118. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  119. extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
  120. struct xfs_name *name, xfs_ino_t inum,
  121. xfs_fsblock_t *first,
  122. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  123. extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
  124. struct xfs_name *name, uint resblks);
  125. /*
  126. * Direct call from the bmap code, bypassing the generic directory layer.
  127. */
  128. extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
  129. /*
  130. * Interface routines used by userspace utilities
  131. */
  132. extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
  133. extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
  134. extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
  135. struct xfs_buf *bp);
  136. extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
  137. struct xfs_dir2_data_hdr *hdr, int *loghead);
  138. extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_inode *dp,
  139. struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
  140. extern void xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_inode *dp,
  141. struct xfs_buf *bp);
  142. extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp,
  143. struct xfs_dir2_data_unused *dup);
  144. extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_inode *dp,
  145. struct xfs_buf *bp, xfs_dir2_data_aoff_t offset,
  146. xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
  147. extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_inode *dp,
  148. struct xfs_buf *bp, struct xfs_dir2_data_unused *dup,
  149. xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
  150. int *needlogp, int *needscanp);
  151. extern struct xfs_dir2_data_free *xfs_dir2_data_freefind(
  152. struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
  153. struct xfs_dir2_data_unused *dup);
  154. extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
  155. extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops;
  156. extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
  157. extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
  158. extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;
  159. #endif /* __XFS_DIR2_H__ */