xfs_dir.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_DIR_H__
  33. #define __XFS_DIR_H__
  34. /*
  35. * Large directories are structured around Btrees where all the data
  36. * elements are in the leaf nodes. Filenames are hashed into an int,
  37. * then that int is used as the index into the Btree. Since the hashval
  38. * of a filename may not be unique, we may have duplicate keys. The
  39. * internal links in the Btree are logical block offsets into the file.
  40. *
  41. * Small directories use a different format and are packed as tightly
  42. * as possible so as to fit into the literal area of the inode.
  43. */
  44. /*========================================================================
  45. * Function prototypes for the kernel.
  46. *========================================================================*/
  47. struct uio;
  48. struct xfs_bmap_free;
  49. struct xfs_da_args;
  50. struct xfs_dinode;
  51. struct xfs_inode;
  52. struct xfs_mount;
  53. struct xfs_trans;
  54. /*
  55. * Directory function types.
  56. * Put in structures (xfs_dirops_t) for v1 and v2 directories.
  57. */
  58. typedef void (*xfs_dir_mount_t)(struct xfs_mount *mp);
  59. typedef int (*xfs_dir_isempty_t)(struct xfs_inode *dp);
  60. typedef int (*xfs_dir_init_t)(struct xfs_trans *tp,
  61. struct xfs_inode *dp,
  62. struct xfs_inode *pdp);
  63. typedef int (*xfs_dir_createname_t)(struct xfs_trans *tp,
  64. struct xfs_inode *dp,
  65. char *name,
  66. int namelen,
  67. xfs_ino_t inum,
  68. xfs_fsblock_t *first,
  69. struct xfs_bmap_free *flist,
  70. xfs_extlen_t total);
  71. typedef int (*xfs_dir_lookup_t)(struct xfs_trans *tp,
  72. struct xfs_inode *dp,
  73. char *name,
  74. int namelen,
  75. xfs_ino_t *inum);
  76. typedef int (*xfs_dir_removename_t)(struct xfs_trans *tp,
  77. struct xfs_inode *dp,
  78. char *name,
  79. int namelen,
  80. xfs_ino_t ino,
  81. xfs_fsblock_t *first,
  82. struct xfs_bmap_free *flist,
  83. xfs_extlen_t total);
  84. typedef int (*xfs_dir_getdents_t)(struct xfs_trans *tp,
  85. struct xfs_inode *dp,
  86. struct uio *uio,
  87. int *eofp);
  88. typedef int (*xfs_dir_replace_t)(struct xfs_trans *tp,
  89. struct xfs_inode *dp,
  90. char *name,
  91. int namelen,
  92. xfs_ino_t inum,
  93. xfs_fsblock_t *first,
  94. struct xfs_bmap_free *flist,
  95. xfs_extlen_t total);
  96. typedef int (*xfs_dir_canenter_t)(struct xfs_trans *tp,
  97. struct xfs_inode *dp,
  98. char *name,
  99. int namelen);
  100. typedef int (*xfs_dir_shortform_validate_ondisk_t)(struct xfs_mount *mp,
  101. struct xfs_dinode *dip);
  102. typedef int (*xfs_dir_shortform_to_single_t)(struct xfs_da_args *args);
  103. typedef struct xfs_dirops {
  104. xfs_dir_mount_t xd_mount;
  105. xfs_dir_isempty_t xd_isempty;
  106. xfs_dir_init_t xd_init;
  107. xfs_dir_createname_t xd_createname;
  108. xfs_dir_lookup_t xd_lookup;
  109. xfs_dir_removename_t xd_removename;
  110. xfs_dir_getdents_t xd_getdents;
  111. xfs_dir_replace_t xd_replace;
  112. xfs_dir_canenter_t xd_canenter;
  113. xfs_dir_shortform_validate_ondisk_t xd_shortform_validate_ondisk;
  114. xfs_dir_shortform_to_single_t xd_shortform_to_single;
  115. } xfs_dirops_t;
  116. /*
  117. * Overall external interface routines.
  118. */
  119. void xfs_dir_startup(void); /* called exactly once */
  120. #define XFS_DIR_MOUNT(mp) \
  121. ((mp)->m_dirops.xd_mount(mp))
  122. #define XFS_DIR_ISEMPTY(mp,dp) \
  123. ((mp)->m_dirops.xd_isempty(dp))
  124. #define XFS_DIR_INIT(mp,tp,dp,pdp) \
  125. ((mp)->m_dirops.xd_init(tp,dp,pdp))
  126. #define XFS_DIR_CREATENAME(mp,tp,dp,name,namelen,inum,first,flist,total) \
  127. ((mp)->m_dirops.xd_createname(tp,dp,name,namelen,inum,first,flist,\
  128. total))
  129. #define XFS_DIR_LOOKUP(mp,tp,dp,name,namelen,inum) \
  130. ((mp)->m_dirops.xd_lookup(tp,dp,name,namelen,inum))
  131. #define XFS_DIR_REMOVENAME(mp,tp,dp,name,namelen,ino,first,flist,total) \
  132. ((mp)->m_dirops.xd_removename(tp,dp,name,namelen,ino,first,flist,total))
  133. #define XFS_DIR_GETDENTS(mp,tp,dp,uio,eofp) \
  134. ((mp)->m_dirops.xd_getdents(tp,dp,uio,eofp))
  135. #define XFS_DIR_REPLACE(mp,tp,dp,name,namelen,inum,first,flist,total) \
  136. ((mp)->m_dirops.xd_replace(tp,dp,name,namelen,inum,first,flist,total))
  137. #define XFS_DIR_CANENTER(mp,tp,dp,name,namelen) \
  138. ((mp)->m_dirops.xd_canenter(tp,dp,name,namelen))
  139. #define XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp,dip) \
  140. ((mp)->m_dirops.xd_shortform_validate_ondisk(mp,dip))
  141. #define XFS_DIR_SHORTFORM_TO_SINGLE(mp,args) \
  142. ((mp)->m_dirops.xd_shortform_to_single(args))
  143. #define XFS_DIR_IS_V1(mp) ((mp)->m_dirversion == 1)
  144. extern xfs_dirops_t xfsv1_dirops;
  145. #endif /* __XFS_DIR_H__ */