]>
Commit | Line | Data |
---|---|---|
9bccf70c A |
1 | /* |
2 | * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
9bccf70c | 7 | * |
d7e50217 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
9bccf70c A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
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. | |
9bccf70c A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | #ifndef __HFS_CATALOG__ | |
26 | #define __HFS_CATALOG__ | |
27 | ||
28 | #include <sys/appleapiopts.h> | |
29 | ||
30 | #ifdef KERNEL | |
31 | #ifdef __APPLE_API_PRIVATE | |
32 | #include <sys/namei.h> | |
33 | #include <sys/vnode.h> | |
34 | #include <sys/lock.h> | |
35 | ||
36 | #include <hfs/hfs_format.h> | |
37 | ||
38 | /* HFS Catalog */ | |
39 | ||
40 | ||
41 | /* | |
42 | * Catalog ADTs | |
43 | * | |
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). | |
48 | */ | |
49 | ||
50 | typedef u_int32_t cnid_t; | |
51 | ||
52 | /* | |
53 | * Catalog Node Descriptor (runtime) | |
54 | */ | |
55 | struct cat_desc { | |
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) */ | |
63 | }; | |
64 | ||
65 | /* cd_flags */ | |
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 */ | |
69 | ||
70 | /* | |
71 | * Catalog Node Attributes (runtime) | |
72 | */ | |
73 | struct cat_attr { | |
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) */ | |
87 | union { | |
88 | u_int32_t cau_blocks; /* total file blocks used (rsrc + data) */ | |
89 | u_int32_t cau_entries; /* total directory entries (valence) */ | |
90 | } ca_union; | |
91 | u_int8_t ca_finderinfo[32]; /* Opaque Finder information */ | |
92 | }; | |
93 | /* Aliases for common fields */ | |
94 | #define ca_blocks ca_union.cau_blocks | |
95 | #define ca_entries ca_union.cau_entries | |
96 | ||
97 | /* | |
98 | * Catalog Node Fork (runtime + on disk) | |
99 | */ | |
100 | struct cat_fork { | |
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 */ | |
105 | }; | |
106 | ||
107 | ||
108 | /* | |
109 | * Catalog Node Entry | |
110 | * | |
111 | * A cat_entry is used for bulk enumerations (hfs_readdirattr). | |
112 | */ | |
113 | struct cat_entry { | |
114 | struct cat_desc ce_desc; | |
115 | struct cat_attr ce_attr; | |
116 | off_t ce_datasize; | |
117 | off_t ce_rsrcsize; | |
118 | u_long ce_datablks; | |
119 | u_long ce_rsrcblks; | |
120 | }; | |
121 | ||
122 | #define MAXCATENTRIES 8 | |
123 | /* | |
124 | * Catalog Node Entry List | |
125 | * | |
126 | * A cat_entrylist is a list of Catalog Node Entries. | |
127 | */ | |
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 */ | |
132 | }; | |
133 | ||
134 | /* | |
135 | * Catalog Interface | |
136 | * | |
137 | * These functions perform a catalog transactions. The | |
138 | * catalog b-tree is abstracted through this interface. | |
139 | * (please don't go around it) | |
140 | */ | |
141 | ||
142 | struct hfsmount; | |
143 | ||
144 | extern void cat_releasedesc(struct cat_desc *descp); | |
145 | ||
146 | extern int cat_create ( struct hfsmount *hfsmp, | |
147 | struct cat_desc *descp, | |
148 | struct cat_attr *attrp, | |
149 | struct cat_desc *out_descp); | |
150 | ||
151 | extern int cat_delete ( struct hfsmount *hfsmp, | |
152 | struct cat_desc *descp, | |
153 | struct cat_attr *attrp); | |
154 | ||
155 | extern int cat_lookup ( struct hfsmount *hfsmp, | |
156 | struct cat_desc *descp, | |
157 | int wantrsrc, | |
158 | struct cat_desc *outdescp, | |
159 | struct cat_attr *attrp, | |
160 | struct cat_fork *forkp); | |
161 | ||
162 | extern int cat_idlookup (struct hfsmount *hfsmp, | |
163 | cnid_t cnid, | |
164 | struct cat_desc *outdescp, | |
165 | struct cat_attr *attrp, | |
166 | struct cat_fork *forkp); | |
167 | ||
168 | extern int cat_getentriesattr( | |
169 | struct hfsmount *hfsmp, | |
170 | struct cat_desc *prevdesc, | |
171 | int index, | |
172 | struct cat_entrylist *ce_list); | |
173 | ||
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); | |
179 | ||
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); | |
185 | ||
186 | extern int cat_getdirentries( | |
187 | struct hfsmount *hfsmp, | |
188 | struct cat_desc *descp, | |
189 | struct uio *uio, | |
190 | int *eofflag); | |
191 | ||
192 | extern int cat_insertfilethread ( | |
193 | struct hfsmount *hfsmp, | |
194 | struct cat_desc *descp); | |
195 | ||
196 | #endif /* __APPLE_API_PRIVATE */ | |
197 | #endif /* KERNEL */ | |
198 | #endif /* __HFS_CATALOG__ */ |