]> git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfscommon/headers/CatalogPrivate.h
xnu-344.tar.gz
[apple/xnu.git] / bsd / hfs / hfscommon / headers / CatalogPrivate.h
1 /*
2 * Copyright (c) 2000, 2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 File: CatalogPrivate.h
24
25 Contains: Private Catalog Manager interfaces.
26
27 Version: HFS Plus 1.0
28
29 Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved.
30
31 File Ownership:
32
33 DRI: Don Brady
34
35 Other Contact: xxx put other contact here xxx
36
37 Technology: xxx put technology here xxx
38
39 Writers:
40
41 (JL) Jim Luther
42 (msd) Mark Day
43 (DSH) Deric Horn
44 (djb) Don Brady
45
46 Change History (most recent first):
47 <MacOSX> 11/10/98 djb Remove obsolete PrepareInputName prototype;
48 <MacOSX> 4/6/98 djb Added lock data stuctures and ReleaseCatalogIterator prototype;
49 <MacOSX> 4/6/98 djb Removed CatalogDataCache since its no longer used.
50 <MacOSX> 4/2/98 djb InvalidateCatalogNodeCache does nothing under MacOS X.
51 <MacOSX> 3/31/98 djb Sync up with final HFSVolumes.h header file.
52
53 <CS10> 11/20/97 djb Radar #2002357. Fixing retry mechanism.
54 <CS9> 11/17/97 djb PrepareInputName routine now returns an error.
55 <CS8> 11/13/97 djb Radar #1683572. Move CatalogIterator to this file from
56 FileMgrInternal.i. Double size of short unicode name.
57 <CS7> 10/31/97 JL #2000184 - Changed prototypes for CreateFileThreadID and
58 ExchangeFiles.
59 <CS6> 10/17/97 msd In CatalogCacheGlobals, add room for a single UniStr255 so
60 catalog iterators can step over long Unicode names.
61 <CS5> 10/17/97 djb Add ConvertInputNameToUnicode for Catalog Create/Rename.
62 <CS4> 10/1/97 djb Change catalog iterator implementation.
63 <CS3> 7/16/97 DSH FilesInternal.i renamed FileMgrInternal.i to avoid name
64 collision
65 <CS2> 6/24/97 djb Add LocateCatalogNodeByMangledName routine.
66 <CS1> 6/24/97 djb first checked in
67 */
68
69 #ifndef __CATALOGPRIVATE__
70 #define __CATALOGPRIVATE__
71
72 #include <sys/appleapiopts.h>
73
74 #ifdef KERNEL
75 #ifdef __APPLE_API_PRIVATE
76
77 #include "../../hfs_format.h"
78
79 #include "FileMgrInternal.h"
80 #include "BTreesInternal.h"
81
82 #include <sys/lock.h>
83
84 // private catalog data cache
85
86
87
88 enum {
89 kCatalogIteratorCount = 16 // total number of Catalog iterators (shared by all HFS/HFS Plus volumes)
90 };
91
92
93 // Catalog Iterator Name Types
94 enum {
95 kShortPascalName,
96 kShortUnicodeName,
97 kLongUnicodeName // non-local name
98 };
99
100
101 // short unicode name (used by CatalogIterator)
102 struct UniStr63 {
103 UInt16 length; /* number of unicode characters */
104 UniChar unicode[63]; /* unicode characters */
105 };
106 typedef struct UniStr63 UniStr63;
107
108
109 struct CatalogIterator
110 {
111 struct CatalogIterator *nextMRU; // next iterator in MRU order
112 struct CatalogIterator *nextLRU; // next iterator in LRU order
113
114 ExtendedVCB *volume;
115 SInt16 currentIndex;
116 SInt16 reserved;
117 UInt32 currentOffset;
118 UInt32 nextOffset;
119 HFSCatalogNodeID folderID;
120
121 UInt32 btreeNodeHint; // node the key was last seen in
122 UInt16 btreeIndexHint; // index the key was last seen at
123 UInt16 nameType; // { 0 = Pascal, 1 = Unicode, 3 = long name}
124 HFSCatalogNodeID parentID; // parent folder ID
125 union
126 {
127 Str31 pascalName;
128 UniStr63 unicodeName;
129 HFSUniStr255 * longNamePtr;
130 } folderName;
131
132 struct lock__bsd__ iterator_lock;
133 };
134 typedef struct CatalogIterator CatalogIterator;
135
136
137 struct CatalogCacheGlobals {
138 UInt32 iteratorCount; // Number of iterators in cache
139 CatalogIterator * mru;
140 CatalogIterator * lru;
141 UInt32 reserved;
142 HFSUniStr255 longName; // used by a single kLongUnicodeName iterator
143
144 simple_lock_data_t simplelock;
145 };
146 typedef struct CatalogCacheGlobals CatalogCacheGlobals;
147
148
149 //
150 // Private Catalog Manager Routines (for use only by Catalog Manager, CatSearch and FileID Services)
151 //
152
153
154 extern OSErr LocateCatalogNode( const ExtendedVCB *volume, HFSCatalogNodeID folderID, const CatalogName *name,
155 UInt32 hint, CatalogKey *key, CatalogRecord *data, UInt32 *newHint);
156
157 extern OSErr LocateCatalogNodeByKey ( const ExtendedVCB *volume, UInt32 hint, CatalogKey *keyPtr,
158 CatalogRecord *dataPtr, UInt32 *newHint );
159
160 extern OSErr LocateCatalogRecord( const ExtendedVCB *volume, HFSCatalogNodeID folderID, const CatalogName *name,
161 UInt32 hint, CatalogKey *keyPtr, CatalogRecord *dataPtr, UInt32 *newHint);
162
163 extern OSErr LocateCatalogNodeWithRetry ( const ExtendedVCB *volume, HFSCatalogNodeID folderID, ConstStr31Param pascalName,
164 CatalogName *unicodeName, UInt32 hint, CatalogKey *keyPtr, CatalogRecord *dataPtr,
165 UInt32 *newHint );
166 extern OSErr FlushCatalog( ExtendedVCB *volume);
167
168
169 extern void ConvertInputNameToUnicode(ConstStr31Param name, TextEncoding encodingHint,
170 TextEncoding *actualEncoding, CatalogName *catalogName);
171
172 extern void BuildCatalogKey( HFSCatalogNodeID parentID, const CatalogName *name, Boolean isHFSPlus,
173 CatalogKey *key);
174
175 extern OSErr BuildCatalogKeyUTF8(ExtendedVCB *volume, HFSCatalogNodeID parentID, const char *name,
176 UInt32 length, CatalogKey *key, UInt32 *textEncoding);
177
178 extern void CopyCatalogName( const CatalogName *srcName, CatalogName *dstName, Boolean isHFSPLus);
179
180 extern OSErr ResolveFileID( ExtendedVCB *vcb, HFSCatalogNodeID fileID, HFSCatalogNodeID *parentID, Str31 name );
181
182 #if 0
183 extern OSErr CreateFileThreadID( FIDParam *filePB, WDCBRecPtr *wdcbPtr );
184
185 extern OSErr ExchangeFiles( FIDParam *filePB, WDCBRecPtr *wdcbPtr );
186 #endif
187
188
189 // Catalog Iterator Routines
190
191 extern CatalogIterator* GetCatalogIterator(ExtendedVCB *volume, HFSCatalogNodeID folderID, UInt32 offset);
192
193 extern OSErr ReleaseCatalogIterator( CatalogIterator *catalogIterator );
194
195 extern void TrashCatalogIterator( const ExtendedVCB *volume, HFSCatalogNodeID folderID );
196
197 void AgeCatalogIterator( CatalogIterator *catalogIterator );
198
199 extern void UpdateBtreeIterator( const CatalogIterator *catalogIterator, BTreeIterator *btreeIterator );
200
201 extern void UpdateCatalogIterator( const BTreeIterator *btreeIterator, CatalogIterator *catalogIterator );
202
203
204 #endif /* __APPLE_API_PRIVATE */
205 #endif /* KERNEL */
206 #endif //__CATALOGPRIVATE__