2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef __HFS_CATALOG__
26 #define __HFS_CATALOG__
28 #include <sys/appleapiopts.h>
31 #ifdef __APPLE_API_PRIVATE
32 #include <sys/namei.h>
33 #include <sys/vnode.h>
36 #include <hfs/hfs_format.h>
44 * The cat_desc, cat_attr, and cat_fork structures are
45 * use to import/export data to/from the Catalog file.
46 * The fields in these structures are always in BSD
47 * runtime format (e.g. dates and names).
50 typedef u_int32_t cnid_t
;
53 * Catalog Node Descriptor (runtime)
56 u_int8_t cd_flags
; /* see below (8 bits) */
57 u_int8_t cd_encoding
; /* name encoding */
58 int16_t cd_namelen
; /* length of cnode name */
59 char * cd_nameptr
; /* pointer to cnode name */
60 cnid_t cd_parentcnid
; /* parent directory CNID */
61 u_long cd_hint
; /* catalog file hint */
62 cnid_t cd_cnid
; /* cnode id (for getattrlist) */
66 #define CD_HASBUF 0x01 /* allocated filename buffer */
67 #define CD_DECOMPOSED 0x02 /* name is fully decomposed */
68 #define CD_ISMETA 0x40 /* describes a metadata file */
69 #define CD_ISDIR 0x80 /* describes a directory */
72 * Catalog Node Attributes (runtime)
75 cnid_t ca_fileid
; /* inode number (for stat) normally == cnid */
76 mode_t ca_mode
; /* file access mode and type (16 bits) */
77 nlink_t ca_nlink
; /* file link count (16 bit integer) */
78 uid_t ca_uid
; /* file owner */
79 gid_t ca_gid
; /* file group */
80 dev_t ca_rdev
; /* device a special file represents */
81 time_t ca_atime
; /* last access time */
82 time_t ca_mtime
; /* last data modification time */
83 int32_t ca_mtime_nsec
; /* last data modification time nanosec */
84 time_t ca_ctime
; /* last file status change */
85 time_t ca_itime
; /* file initialization time */
86 time_t ca_btime
; /* last backup time */
87 u_long ca_flags
; /* status flags (chflags) */
89 u_int32_t cau_blocks
; /* total file blocks used (rsrc + data) */
90 u_int32_t cau_entries
; /* total directory entries (valence) */
92 u_int8_t ca_finderinfo
[32]; /* Opaque Finder information */
94 /* Aliases for common fields */
95 #define ca_blocks ca_union.cau_blocks
96 #define ca_entries ca_union.cau_entries
99 * Catalog Node Fork (runtime)
101 * NOTE: this is not the same as a struct HFSPlusForkData
104 u_int64_t cf_size
; /* fork's logical size in bytes */
106 u_int32_t cfu_clump
; /* fork's clump size in bytes (sys files only) */
107 u_int64_t cfu_bytesread
; /* bytes read from this fork */
109 u_int32_t cf_vblocks
; /* virtual (unalloated) blocks */
110 u_int32_t cf_blocks
; /* total blocks used by this fork */
111 struct HFSPlusExtentDescriptor cf_extents
[8]; /* initial set of extents */
114 #define cf_clump cf_union.cfu_clump
115 #define cf_bytesread cf_union.cfu_bytesread
121 * A cat_entry is used for bulk enumerations (hfs_readdirattr).
124 struct cat_desc ce_desc
;
125 struct cat_attr ce_attr
;
132 #define MAXCATENTRIES 8
134 * Catalog Node Entry List
136 * A cat_entrylist is a list of Catalog Node Entries.
138 struct cat_entrylist
{
139 u_long maxentries
; /* length of list */
140 u_long realentries
; /* valid entry count */
141 struct cat_entry entry
[MAXCATENTRIES
]; /* array of entries */
145 * Catalog Operations Hint
147 * lower 16 bits: count of B-tree insert operations
148 * upper 16 bits: count of B-tree delete operations
151 #define CAT_DELETE 0x00020000
152 #define CAT_CREATE 0x00000002
153 #define CAT_RENAME 0x00020002
154 #define CAT_EXCHANGE 0x00020002
156 typedef u_int32_t catops_t
;
159 * The size of cat_cookie_t much match the size of
160 * the nreserve struct (in BTreeNodeReserve.c).
162 typedef struct cat_cookie_t
{
169 * These functions perform a catalog transactions. The
170 * catalog b-tree is abstracted through this interface.
171 * (please don't go around it)
176 extern void cat_releasedesc(struct cat_desc
*descp
);
178 extern int cat_create ( struct hfsmount
*hfsmp
,
179 struct cat_desc
*descp
,
180 struct cat_attr
*attrp
,
181 struct cat_desc
*out_descp
);
183 extern int cat_delete ( struct hfsmount
*hfsmp
,
184 struct cat_desc
*descp
,
185 struct cat_attr
*attrp
);
187 extern int cat_lookup ( struct hfsmount
*hfsmp
,
188 struct cat_desc
*descp
,
190 struct cat_desc
*outdescp
,
191 struct cat_attr
*attrp
,
192 struct cat_fork
*forkp
);
194 extern int cat_idlookup (struct hfsmount
*hfsmp
,
196 struct cat_desc
*outdescp
,
197 struct cat_attr
*attrp
,
198 struct cat_fork
*forkp
);
200 extern int cat_getentriesattr(
201 struct hfsmount
*hfsmp
,
202 struct cat_desc
*prevdesc
,
204 struct cat_entrylist
*ce_list
);
206 extern int cat_rename ( struct hfsmount
* hfsmp
,
207 struct cat_desc
* from_cdp
,
208 struct cat_desc
* todir_cdp
,
209 struct cat_desc
* to_cdp
,
210 struct cat_desc
* cdp
);
212 extern int cat_update ( struct hfsmount
*hfsmp
,
213 struct cat_desc
*descp
,
214 struct cat_attr
*attrp
,
215 struct cat_fork
*dataforkp
,
216 struct cat_fork
*rsrcforkp
);
218 extern int cat_getdirentries(
219 struct hfsmount
*hfsmp
,
220 struct cat_desc
*descp
,
227 extern int cat_insertfilethread (
228 struct hfsmount
*hfsmp
,
229 struct cat_desc
*descp
);
231 extern int cat_preflight(
232 struct hfsmount
*hfsmp
,
234 cat_cookie_t
*cookie
,
237 extern void cat_postflight(
238 struct hfsmount
*hfsmp
,
239 cat_cookie_t
*cookie
,
242 extern int cat_binarykeycompare(
243 HFSPlusCatalogKey
*searchKey
,
244 HFSPlusCatalogKey
*trialKey
);
246 #endif /* __APPLE_API_PRIVATE */
248 #endif /* __HFS_CATALOG__ */