xfs_dir2_block.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * xfs_dir2_block.h
  22. * Directory version 2, single block format structures
  23. */
  24. struct uio;
  25. struct xfs_dabuf;
  26. struct xfs_da_args;
  27. struct xfs_dir2_data_hdr;
  28. struct xfs_dir2_leaf_entry;
  29. struct xfs_inode;
  30. struct xfs_mount;
  31. struct xfs_trans;
  32. /*
  33. * The single block format is as follows:
  34. * xfs_dir2_data_hdr_t structure
  35. * xfs_dir2_data_entry_t and xfs_dir2_data_unused_t structures
  36. * xfs_dir2_leaf_entry_t structures
  37. * xfs_dir2_block_tail_t structure
  38. */
  39. #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */
  40. typedef struct xfs_dir2_block_tail {
  41. __be32 count; /* count of leaf entries */
  42. __be32 stale; /* count of stale lf entries */
  43. } xfs_dir2_block_tail_t;
  44. /*
  45. * Generic single-block structure, for xfs_db.
  46. */
  47. typedef struct xfs_dir2_block {
  48. xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_BLOCK_MAGIC */
  49. xfs_dir2_data_union_t u[1];
  50. xfs_dir2_leaf_entry_t leaf[1];
  51. xfs_dir2_block_tail_t tail;
  52. } xfs_dir2_block_t;
  53. /*
  54. * Pointer to the leaf header embedded in a data block (1-block format)
  55. */
  56. #define XFS_DIR2_BLOCK_TAIL_P(mp,block) xfs_dir2_block_tail_p(mp,block)
  57. static inline xfs_dir2_block_tail_t *
  58. xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
  59. {
  60. return (((xfs_dir2_block_tail_t *)
  61. ((char *)(block) + (mp)->m_dirblksize)) - 1);
  62. }
  63. /*
  64. * Pointer to the leaf entries embedded in a data block (1-block format)
  65. */
  66. #define XFS_DIR2_BLOCK_LEAF_P(btp) xfs_dir2_block_leaf_p(btp)
  67. static inline struct xfs_dir2_leaf_entry *
  68. xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
  69. {
  70. return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
  71. }
  72. /*
  73. * Function declarations.
  74. */
  75. extern int xfs_dir2_block_addname(struct xfs_da_args *args);
  76. extern int xfs_dir2_block_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
  77. struct uio *uio, int *eofp,
  78. struct xfs_dirent *dbp, xfs_dir2_put_t put);
  79. extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
  80. extern int xfs_dir2_block_removename(struct xfs_da_args *args);
  81. extern int xfs_dir2_block_replace(struct xfs_da_args *args);
  82. extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
  83. struct xfs_dabuf *lbp, struct xfs_dabuf *dbp);
  84. extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
  85. #endif /* __XFS_DIR2_BLOCK_H__ */