2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 * Large directories are structured around Btrees where all the data
37 * elements are in the leaf nodes. Filenames are hashed into an int,
38 * then that int is used as the index into the Btree. Since the hashval
39 * of a filename may not be unique, we may have duplicate keys. The
40 * internal links in the Btree are logical block offsets into the file.
42 * Small directories use a different format and are packed as tightly
43 * as possible so as to fit into the literal area of the inode.
46 /*========================================================================
47 * Function prototypes for the kernel.
48 *========================================================================*/
59 * Directory function types.
60 * Put in structures (xfs_dirops_t) for v1 and v2 directories.
62 typedef void (*xfs_dir_mount_t
)(struct xfs_mount
*mp
);
63 typedef int (*xfs_dir_isempty_t
)(struct xfs_inode
*dp
);
64 typedef int (*xfs_dir_init_t
)(struct xfs_trans
*tp
,
66 struct xfs_inode
*pdp
);
67 typedef int (*xfs_dir_createname_t
)(struct xfs_trans
*tp
,
73 struct xfs_bmap_free
*flist
,
75 typedef int (*xfs_dir_lookup_t
)(struct xfs_trans
*tp
,
80 typedef int (*xfs_dir_removename_t
)(struct xfs_trans
*tp
,
86 struct xfs_bmap_free
*flist
,
88 typedef int (*xfs_dir_getdents_t
)(struct xfs_trans
*tp
,
92 typedef int (*xfs_dir_replace_t
)(struct xfs_trans
*tp
,
98 struct xfs_bmap_free
*flist
,
100 typedef int (*xfs_dir_canenter_t
)(struct xfs_trans
*tp
,
101 struct xfs_inode
*dp
,
104 typedef int (*xfs_dir_shortform_validate_ondisk_t
)(struct xfs_mount
*mp
,
105 struct xfs_dinode
*dip
);
106 typedef int (*xfs_dir_shortform_to_single_t
)(struct xfs_da_args
*args
);
108 typedef struct xfs_dirops
{
109 xfs_dir_mount_t xd_mount
;
110 xfs_dir_isempty_t xd_isempty
;
111 xfs_dir_init_t xd_init
;
112 xfs_dir_createname_t xd_createname
;
113 xfs_dir_lookup_t xd_lookup
;
114 xfs_dir_removename_t xd_removename
;
115 xfs_dir_getdents_t xd_getdents
;
116 xfs_dir_replace_t xd_replace
;
117 xfs_dir_canenter_t xd_canenter
;
118 xfs_dir_shortform_validate_ondisk_t xd_shortform_validate_ondisk
;
119 xfs_dir_shortform_to_single_t xd_shortform_to_single
;
123 * Overall external interface routines.
125 void xfs_dir_startup(void); /* called exactly once */
127 #define XFS_DIR_MOUNT(mp) \
128 ((mp)->m_dirops.xd_mount(mp))
129 #define XFS_DIR_ISEMPTY(mp,dp) \
130 ((mp)->m_dirops.xd_isempty(dp))
131 #define XFS_DIR_INIT(mp,tp,dp,pdp) \
132 ((mp)->m_dirops.xd_init(tp,dp,pdp))
133 #define XFS_DIR_CREATENAME(mp,tp,dp,name,namelen,inum,first,flist,total) \
134 ((mp)->m_dirops.xd_createname(tp,dp,name,namelen,inum,first,flist,\
136 #define XFS_DIR_LOOKUP(mp,tp,dp,name,namelen,inum) \
137 ((mp)->m_dirops.xd_lookup(tp,dp,name,namelen,inum))
138 #define XFS_DIR_REMOVENAME(mp,tp,dp,name,namelen,ino,first,flist,total) \
139 ((mp)->m_dirops.xd_removename(tp,dp,name,namelen,ino,first,flist,total))
140 #define XFS_DIR_GETDENTS(mp,tp,dp,uio,eofp) \
141 ((mp)->m_dirops.xd_getdents(tp,dp,uio,eofp))
142 #define XFS_DIR_REPLACE(mp,tp,dp,name,namelen,inum,first,flist,total) \
143 ((mp)->m_dirops.xd_replace(tp,dp,name,namelen,inum,first,flist,total))
144 #define XFS_DIR_CANENTER(mp,tp,dp,name,namelen) \
145 ((mp)->m_dirops.xd_canenter(tp,dp,name,namelen))
146 #define XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp,dip) \
147 ((mp)->m_dirops.xd_shortform_validate_ondisk(mp,dip))
148 #define XFS_DIR_SHORTFORM_TO_SINGLE(mp,args) \
149 ((mp)->m_dirops.xd_shortform_to_single(args))
151 #define XFS_DIR_IS_V1(mp) ((mp)->m_dirversion == 1)
152 extern xfs_dirops_t xfsv1_dirops
;
154 #endif /* __XFS_DIR_H__ */