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