xfs_dir2.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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)(void);
  58. xfs_dir2_data_aoff_t (*data_dotdot_offset)(void);
  59. xfs_dir2_data_aoff_t (*data_first_offset)(void);
  60. size_t (*data_entry_offset)(void);
  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. };
  72. extern const struct xfs_dir_ops xfs_dir2_ops;
  73. extern const struct xfs_dir_ops xfs_dir2_ftype_ops;
  74. extern const struct xfs_dir_ops xfs_dir3_ops;
  75. /*
  76. * Generic directory interface routines
  77. */
  78. extern void xfs_dir_startup(void);
  79. extern void xfs_dir_mount(struct xfs_mount *mp);
  80. extern int xfs_dir_isempty(struct xfs_inode *dp);
  81. extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
  82. struct xfs_inode *pdp);
  83. extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
  84. struct xfs_name *name, xfs_ino_t inum,
  85. xfs_fsblock_t *first,
  86. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  87. extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
  88. struct xfs_name *name, xfs_ino_t *inum,
  89. struct xfs_name *ci_name);
  90. extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
  91. struct xfs_name *name, xfs_ino_t ino,
  92. xfs_fsblock_t *first,
  93. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  94. extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
  95. struct xfs_name *name, xfs_ino_t inum,
  96. xfs_fsblock_t *first,
  97. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  98. extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
  99. struct xfs_name *name, uint resblks);
  100. /*
  101. * Direct call from the bmap code, bypassing the generic directory layer.
  102. */
  103. extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
  104. /*
  105. * Interface routines used by userspace utilities
  106. */
  107. extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
  108. extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
  109. extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
  110. struct xfs_buf *bp);
  111. extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
  112. struct xfs_dir2_data_hdr *hdr, int *loghead);
  113. extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_inode *dp,
  114. struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
  115. extern void xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_inode *dp,
  116. struct xfs_buf *bp);
  117. extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp,
  118. struct xfs_dir2_data_unused *dup);
  119. extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_inode *dp,
  120. struct xfs_buf *bp, xfs_dir2_data_aoff_t offset,
  121. xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
  122. extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_inode *dp,
  123. struct xfs_buf *bp, struct xfs_dir2_data_unused *dup,
  124. xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
  125. int *needlogp, int *needscanp);
  126. extern struct xfs_dir2_data_free *xfs_dir2_data_freefind(
  127. struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
  128. struct xfs_dir2_data_unused *dup);
  129. extern const struct xfs_buf_ops xfs_dir3_block_buf_ops;
  130. extern const struct xfs_buf_ops xfs_dir3_leafn_buf_ops;
  131. extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
  132. extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
  133. extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;
  134. #endif /* __XFS_DIR2_H__ */