2 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef __HFS_CATALOG__
23 #define __HFS_CATALOG__
25 #include <sys/appleapiopts.h>
28 #ifdef __APPLE_API_PRIVATE
29 #include <sys/namei.h>
30 #include <sys/vnode.h>
33 #include <hfs/hfs_format.h>
41 * The cat_desc, cat_attr, and cat_fork structures are
42 * use to import/export data to/from the Catalog file.
43 * The fields in these structures are always in BSD
44 * runtime format (e.g. dates and names).
47 typedef u_int32_t cnid_t
;
50 * Catalog Node Descriptor (runtime)
53 u_int8_t cd_flags
; /* see below (8 bits) */
54 u_int8_t cd_encoding
; /* name encoding */
55 int16_t cd_namelen
; /* length of cnode name */
56 char * cd_nameptr
; /* pointer to cnode name */
57 cnid_t cd_parentcnid
; /* parent directory CNID */
58 u_long cd_hint
; /* catalog file hint */
59 cnid_t cd_cnid
; /* cnode id (for getattrlist) */
63 #define CD_HASBUF 0x01 /* allocated filename buffer */
64 #define CD_DECOMPOSED 0x02 /* name is fully decomposed */
65 #define CD_ISDIR 0x80 /* describes a directory */
68 * Catalog Node Attributes (runtime)
71 cnid_t ca_fileid
; /* inode number (for stat) normally == cnid */
72 mode_t ca_mode
; /* file access mode and type (16 bits) */
73 nlink_t ca_nlink
; /* file link count (16 bit integer) */
74 uid_t ca_uid
; /* file owner */
75 gid_t ca_gid
; /* file group */
76 dev_t ca_rdev
; /* device a special file represents */
77 time_t ca_atime
; /* last access time */
78 time_t ca_mtime
; /* last data modification time */
79 int32_t ca_mtime_nsec
; /* last data modification time nanosec */
80 time_t ca_ctime
; /* last file status change */
81 time_t ca_itime
; /* file initialization time */
82 time_t ca_btime
; /* last backup time */
83 u_long ca_flags
; /* status flags (chflags) */
85 u_int32_t cau_blocks
; /* total file blocks used (rsrc + data) */
86 u_int32_t cau_entries
; /* total directory entries (valence) */
88 u_int8_t ca_finderinfo
[32]; /* Opaque Finder information */
90 /* Aliases for common fields */
91 #define ca_blocks ca_union.cau_blocks
92 #define ca_entries ca_union.cau_entries
95 * Catalog Node Fork (runtime + on disk)
98 u_int64_t cf_size
; /* fork's logical size in bytes */
99 u_int32_t cf_clump
; /* fork's clump size in bytes */
100 u_int32_t cf_blocks
; /* total blocks used by this fork */
101 struct HFSPlusExtentDescriptor cf_extents
[8]; /* initial set of extents */
108 * A cat_entry is used for bulk enumerations (hfs_readdirattr).
111 struct cat_desc ce_desc
;
112 struct cat_attr ce_attr
;
119 #define MAXCATENTRIES 8
121 * Catalog Node Entry List
123 * A cat_entrylist is a list of Catalog Node Entries.
125 struct cat_entrylist
{
126 u_long maxentries
; /* length of list */
127 u_long realentries
; /* valid entry count */
128 struct cat_entry entry
[MAXCATENTRIES
]; /* array of entries */
134 * These functions perform a catalog transactions. The
135 * catalog b-tree is abstracted through this interface.
136 * (please don't go around it)
141 extern void cat_releasedesc(struct cat_desc
*descp
);
143 extern int cat_create ( struct hfsmount
*hfsmp
,
144 struct cat_desc
*descp
,
145 struct cat_attr
*attrp
,
146 struct cat_desc
*out_descp
);
148 extern int cat_delete ( struct hfsmount
*hfsmp
,
149 struct cat_desc
*descp
,
150 struct cat_attr
*attrp
);
152 extern int cat_lookup ( struct hfsmount
*hfsmp
,
153 struct cat_desc
*descp
,
155 struct cat_desc
*outdescp
,
156 struct cat_attr
*attrp
,
157 struct cat_fork
*forkp
);
159 extern int cat_idlookup (struct hfsmount
*hfsmp
,
161 struct cat_desc
*outdescp
,
162 struct cat_attr
*attrp
,
163 struct cat_fork
*forkp
);
165 extern int cat_getentriesattr(
166 struct hfsmount
*hfsmp
,
167 struct cat_desc
*prevdesc
,
169 struct cat_entrylist
*ce_list
);
171 extern int cat_rename ( struct hfsmount
* hfsmp
,
172 struct cat_desc
* from_cdp
,
173 struct cat_desc
* todir_cdp
,
174 struct cat_desc
* to_cdp
,
175 struct cat_desc
* cdp
);
177 extern int cat_update ( struct hfsmount
*hfsmp
,
178 struct cat_desc
*descp
,
179 struct cat_attr
*attrp
,
180 struct cat_fork
*dataforkp
,
181 struct cat_fork
*rsrcforkp
);
183 extern int cat_getdirentries(
184 struct hfsmount
*hfsmp
,
185 struct cat_desc
*descp
,
189 extern int cat_insertfilethread (
190 struct hfsmount
*hfsmp
,
191 struct cat_desc
*descp
);
193 #endif /* __APPLE_API_PRIVATE */
195 #endif /* __HFS_CATALOG__ */