2 * Copyright (c) 2002 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_ISDIR 0x80 /* describes a directory */
71 * Catalog Node Attributes (runtime)
74 cnid_t ca_fileid
; /* inode number (for stat) normally == cnid */
75 mode_t ca_mode
; /* file access mode and type (16 bits) */
76 nlink_t ca_nlink
; /* file link count (16 bit integer) */
77 uid_t ca_uid
; /* file owner */
78 gid_t ca_gid
; /* file group */
79 dev_t ca_rdev
; /* device a special file represents */
80 time_t ca_atime
; /* last access time */
81 time_t ca_mtime
; /* last data modification time */
82 int32_t ca_mtime_nsec
; /* last data modification time nanosec */
83 time_t ca_ctime
; /* last file status change */
84 time_t ca_itime
; /* file initialization time */
85 time_t ca_btime
; /* last backup time */
86 u_long ca_flags
; /* status flags (chflags) */
88 u_int32_t cau_blocks
; /* total file blocks used (rsrc + data) */
89 u_int32_t cau_entries
; /* total directory entries (valence) */
91 u_int8_t ca_finderinfo
[32]; /* Opaque Finder information */
93 /* Aliases for common fields */
94 #define ca_blocks ca_union.cau_blocks
95 #define ca_entries ca_union.cau_entries
98 * Catalog Node Fork (runtime + on disk)
101 u_int64_t cf_size
; /* fork's logical size in bytes */
102 u_int32_t cf_clump
; /* fork's clump size in bytes */
103 u_int32_t cf_blocks
; /* total blocks used by this fork */
104 struct HFSPlusExtentDescriptor cf_extents
[8]; /* initial set of extents */
111 * A cat_entry is used for bulk enumerations (hfs_readdirattr).
114 struct cat_desc ce_desc
;
115 struct cat_attr ce_attr
;
122 #define MAXCATENTRIES 8
124 * Catalog Node Entry List
126 * A cat_entrylist is a list of Catalog Node Entries.
128 struct cat_entrylist
{
129 u_long maxentries
; /* length of list */
130 u_long realentries
; /* valid entry count */
131 struct cat_entry entry
[MAXCATENTRIES
]; /* array of entries */
137 * These functions perform a catalog transactions. The
138 * catalog b-tree is abstracted through this interface.
139 * (please don't go around it)
144 extern void cat_releasedesc(struct cat_desc
*descp
);
146 extern int cat_create ( struct hfsmount
*hfsmp
,
147 struct cat_desc
*descp
,
148 struct cat_attr
*attrp
,
149 struct cat_desc
*out_descp
);
151 extern int cat_delete ( struct hfsmount
*hfsmp
,
152 struct cat_desc
*descp
,
153 struct cat_attr
*attrp
);
155 extern int cat_lookup ( struct hfsmount
*hfsmp
,
156 struct cat_desc
*descp
,
158 struct cat_desc
*outdescp
,
159 struct cat_attr
*attrp
,
160 struct cat_fork
*forkp
);
162 extern int cat_idlookup (struct hfsmount
*hfsmp
,
164 struct cat_desc
*outdescp
,
165 struct cat_attr
*attrp
,
166 struct cat_fork
*forkp
);
168 extern int cat_getentriesattr(
169 struct hfsmount
*hfsmp
,
170 struct cat_desc
*prevdesc
,
172 struct cat_entrylist
*ce_list
);
174 extern int cat_rename ( struct hfsmount
* hfsmp
,
175 struct cat_desc
* from_cdp
,
176 struct cat_desc
* todir_cdp
,
177 struct cat_desc
* to_cdp
,
178 struct cat_desc
* cdp
);
180 extern int cat_update ( struct hfsmount
*hfsmp
,
181 struct cat_desc
*descp
,
182 struct cat_attr
*attrp
,
183 struct cat_fork
*dataforkp
,
184 struct cat_fork
*rsrcforkp
);
186 extern int cat_getdirentries(
187 struct hfsmount
*hfsmp
,
188 struct cat_desc
*descp
,
192 extern int cat_insertfilethread (
193 struct hfsmount
*hfsmp
,
194 struct cat_desc
*descp
);
196 #endif /* __APPLE_API_PRIVATE */
198 #endif /* __HFS_CATALOG__ */