xfs_dir2.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 uio;
  21. struct xfs_dabuf;
  22. struct xfs_da_args;
  23. struct xfs_dir2_put_args;
  24. struct xfs_bmap_free;
  25. struct xfs_inode;
  26. struct xfs_mount;
  27. struct xfs_trans;
  28. /*
  29. * Directory version 2.
  30. * There are 4 possible formats:
  31. * shortform
  32. * single block - data with embedded leaf at the end
  33. * multiple data blocks, single leaf+freeindex block
  34. * data blocks, node&leaf blocks (btree), freeindex blocks
  35. *
  36. * The shortform format is in xfs_dir2_sf.h.
  37. * The single block format is in xfs_dir2_block.h.
  38. * The data block format is in xfs_dir2_data.h.
  39. * The leaf and freeindex block formats are in xfs_dir2_leaf.h.
  40. * Node blocks are the same as the other version, in xfs_da_btree.h.
  41. */
  42. /*
  43. * Byte offset in data block and shortform entry.
  44. */
  45. typedef __uint16_t xfs_dir2_data_off_t;
  46. #define NULLDATAOFF 0xffffU
  47. typedef uint xfs_dir2_data_aoff_t; /* argument form */
  48. /*
  49. * Directory block number (logical dirblk in file)
  50. */
  51. typedef __uint32_t xfs_dir2_db_t;
  52. /*
  53. * Byte offset in a directory.
  54. */
  55. typedef xfs_off_t xfs_dir2_off_t;
  56. /*
  57. * For getdents, argument struct for put routines.
  58. */
  59. typedef int (*xfs_dir2_put_t)(struct xfs_dir2_put_args *pa);
  60. typedef struct xfs_dir2_put_args {
  61. xfs_off_t cook; /* cookie of (next) entry */
  62. xfs_intino_t ino; /* inode number */
  63. xfs_dirent_t *dbp; /* buffer pointer */
  64. char *name; /* directory entry name */
  65. int namelen; /* length of name */
  66. int done; /* output: set if value was stored */
  67. xfs_dir2_put_t put; /* put function ptr (i/o) */
  68. struct uio *uio; /* uio control structure */
  69. } xfs_dir2_put_args_t;
  70. /*
  71. * Generic directory interface routines
  72. */
  73. extern void xfs_dir_startup(void);
  74. extern void xfs_dir_mount(struct xfs_mount *mp);
  75. extern int xfs_dir_isempty(struct xfs_inode *dp);
  76. extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
  77. struct xfs_inode *pdp);
  78. extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
  79. char *name, int namelen, xfs_ino_t inum,
  80. xfs_fsblock_t *first,
  81. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  82. extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
  83. char *name, int namelen, xfs_ino_t *inum);
  84. extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
  85. char *name, int namelen, xfs_ino_t ino,
  86. xfs_fsblock_t *first,
  87. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  88. extern int xfs_dir_getdents(struct xfs_trans *tp, struct xfs_inode *dp,
  89. uio_t *uio, int *eofp);
  90. extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
  91. char *name, int namelen, xfs_ino_t inum,
  92. xfs_fsblock_t *first,
  93. struct xfs_bmap_free *flist, xfs_extlen_t tot);
  94. extern int xfs_dir_canenter(struct xfs_trans *tp, struct xfs_inode *dp,
  95. char *name, int namelen);
  96. extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
  97. /*
  98. * Utility routines for v2 directories.
  99. */
  100. extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
  101. xfs_dir2_db_t *dbp);
  102. extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp,
  103. int *vp);
  104. extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp,
  105. int *vp);
  106. extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
  107. struct xfs_dabuf *bp);
  108. #endif /* __XFS_DIR2_H__ */