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/
41 static int dir_sf_entry_name_count(void *obj
, int startoff
);
42 static int dir_shortform_list_count(void *obj
, int startoff
);
43 static int dir_shortform_list_offset(void *obj
, int startoff
, int idx
);
45 #define OFF(f) bitize(offsetof(xfs_dir_shortform_t, f))
46 const field_t dir_shortform_flds
[] = {
47 { "hdr", FLDT_DIR_SF_HDR
, OI(OFF(hdr
)), C1
, 0, TYP_NONE
},
48 { "list", FLDT_DIR_SF_ENTRY
, dir_shortform_list_offset
,
49 dir_shortform_list_count
, FLD_ARRAY
|FLD_COUNT
|FLD_OFFSET
, TYP_NONE
},
53 #define HOFF(f) bitize(offsetof(xfs_dir_sf_hdr_t, f))
54 const field_t dir_sf_hdr_flds
[] = {
55 { "parent", FLDT_DIR_INO
, OI(HOFF(parent
)), C1
, 0, TYP_INODE
},
56 { "count", FLDT_UINT8D
, OI(HOFF(count
)), C1
, 0, TYP_NONE
},
60 #define EOFF(f) bitize(offsetof(xfs_dir_sf_entry_t, f))
61 const field_t dir_sf_entry_flds
[] = {
62 { "inumber", FLDT_DIR_INO
, OI(EOFF(inumber
)), C1
, 0, TYP_INODE
},
63 { "namelen", FLDT_UINT8D
, OI(EOFF(namelen
)), C1
, 0, TYP_NONE
},
64 { "name", FLDT_CHARNS
, OI(EOFF(name
)), dir_sf_entry_name_count
,
65 FLD_COUNT
, TYP_NONE
},
70 dir_sf_entry_name_count(
74 xfs_dir_sf_entry_t
*e
;
76 ASSERT(bitoffs(startoff
) == 0);
77 e
= (xfs_dir_sf_entry_t
*)((char *)obj
+ byteize(startoff
));
87 xfs_dir_sf_entry_t
*e
;
89 xfs_dir_shortform_t
*sf
;
91 ASSERT(bitoffs(startoff
) == 0);
92 sf
= (xfs_dir_shortform_t
*)((char *)obj
+ byteize(startoff
));
94 for (i
= 0; i
< idx
; i
++)
95 e
= XFS_DIR_SF_NEXTENTRY(e
);
96 return bitize((int)XFS_DIR_SF_ENTSIZE_BYENTRY(e
));
100 dir_shortform_list_count(
104 xfs_dir_shortform_t
*sf
;
106 ASSERT(bitoffs(startoff
) == 0);
107 sf
= (xfs_dir_shortform_t
*)((char *)obj
+ byteize(startoff
));
108 return sf
->hdr
.count
;
112 dir_shortform_list_offset(
117 xfs_dir_sf_entry_t
*e
;
119 xfs_dir_shortform_t
*sf
;
121 ASSERT(bitoffs(startoff
) == 0);
122 sf
= (xfs_dir_shortform_t
*)((char *)obj
+ byteize(startoff
));
124 for (i
= 0; i
< idx
; i
++)
125 e
= XFS_DIR_SF_NEXTENTRY(e
);
126 return bitize((int)((char *)e
- (char *)sf
));
135 xfs_dir_sf_entry_t
*e
;
137 xfs_dir_shortform_t
*sf
;
139 ASSERT(bitoffs(startoff
) == 0);
141 sf
= (xfs_dir_shortform_t
*)((char *)obj
+ byteize(startoff
));
143 for (i
= 0; i
< sf
->hdr
.count
; i
++)
144 e
= XFS_DIR_SF_NEXTENTRY(e
);
145 return bitize((int)((char *)e
- (char *)sf
));