xfs_dir2_block.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_BLOCK_H__
  19. #define __XFS_DIR2_BLOCK_H__
  20. /*
  21. * Directory version 2, single block format structures.
  22. *
  23. * The single block format looks like the following drawing on disk:
  24. *
  25. * +-------------------------------------------------+
  26. * | xfs_dir2_data_hdr_t |
  27. * +-------------------------------------------------+
  28. * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
  29. * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
  30. * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
  31. * | ... |
  32. * +-------------------------------------------------+
  33. * | unused space |
  34. * +-------------------------------------------------+
  35. * | ... |
  36. * | xfs_dir2_leaf_entry_t |
  37. * | xfs_dir2_leaf_entry_t |
  38. * +-------------------------------------------------+
  39. * | xfs_dir2_block_tail_t |
  40. * +-------------------------------------------------+
  41. *
  42. * As all the entries are variable size structures the accessors in this
  43. * file and xfs_dir2_data.h should be used to iterate over them.
  44. */
  45. struct uio;
  46. struct xfs_dabuf;
  47. struct xfs_da_args;
  48. struct xfs_dir2_data_hdr;
  49. struct xfs_dir2_leaf_entry;
  50. struct xfs_inode;
  51. struct xfs_mount;
  52. struct xfs_trans;
  53. #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */
  54. typedef struct xfs_dir2_block_tail {
  55. __be32 count; /* count of leaf entries */
  56. __be32 stale; /* count of stale lf entries */
  57. } xfs_dir2_block_tail_t;
  58. /*
  59. * Pointer to the leaf header embedded in a data block (1-block format)
  60. */
  61. static inline xfs_dir2_block_tail_t *
  62. xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_data_hdr_t *hdr)
  63. {
  64. return ((xfs_dir2_block_tail_t *)((char *)hdr + mp->m_dirblksize)) - 1;
  65. }
  66. /*
  67. * Pointer to the leaf entries embedded in a data block (1-block format)
  68. */
  69. static inline struct xfs_dir2_leaf_entry *
  70. xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
  71. {
  72. return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
  73. }
  74. /*
  75. * Function declarations.
  76. */
  77. extern int xfs_dir2_block_addname(struct xfs_da_args *args);
  78. extern int xfs_dir2_block_getdents(struct xfs_inode *dp, void *dirent,
  79. xfs_off_t *offset, filldir_t filldir);
  80. extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
  81. extern int xfs_dir2_block_removename(struct xfs_da_args *args);
  82. extern int xfs_dir2_block_replace(struct xfs_da_args *args);
  83. extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
  84. struct xfs_dabuf *lbp, struct xfs_dabuf *dbp);
  85. extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
  86. #endif /* __XFS_DIR2_BLOCK_H__ */