2 * Copyright (c) 2000 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@
25 Contains: IPI for File Manager (HFS Plus)
29 Copyright: © 1996-1999 by Apple Computer, Inc., all rights reserved.
35 Other Contacts: Mark Day, Deric horn, Jim Luther
37 Technology: File Systems
46 Change History (most recent first):
47 <MOSXS> 9/12/99 ser Removed FCBs.
48 <MOSX> 9/9/99 pwd Fixed some VCB fields to be unsigned instead of signed to align
49 the definitions with the MDB/volume header and actual use [#2355889].
50 <MOSXS> 9/3/99 ser Added kUndefinedStrLen.
51 <MOSXS> 6/3/99 djb Removed unused/legacy vcb fields from ExtendedVCB.
52 <MOSXS> 11/20/98 djb Add support for UTF-8 names.
53 <MOSXS> 8/31/98 djb Added boolean flag to GetTimeLocal prototype.
54 <MOSXS> 6/30/98 djb Add NodesAreContiguous prototype (for radar #2249539).
55 <MOSXS> 6/22/98 djb Add ERR_BASE to error codes to make them negative (for MacOS X only).
56 Replace DeallocFile prototype with DeleteFile prototype.
57 <MOSXS> 6/5/98 djb Added CreateFileIDRef prototype;
58 <MOSXS> 6/3/98 djb Add MoveRenameCatalogNode prototype (replaces seperate Move and Rename).
59 <MOSXS> 4/17/98 djb Add VCB locking.
60 <MOSXS> 4/6/98 djb Removed CreateVolumeCatalogCache and DisposeVolumeCatalogCache (obsolete).
61 <MOSXS> 4/2/98 djb UpdateCatalogNode now takes parID and name as input.
62 <MOSXS> 3/31/98 djb Sync up with final HFSVolumes.h header file.
63 <MOSXS> 3/17/98 djb Fixed CreateCatalogNode interface to take kCatalogFolderNode and
64 kCatalogFileNode as type input.
66 <CS30> 1/29/98 DSH Added TrashVolumeDiskCache prototype for TrashAllFSCaches API
68 <CS29> 12/10/97 DSH 2201501, Overload the NodeData valence field for over 2 Gig file
70 <CS28> 11/18/97 DSH Conditionalize ou BlockCameFromDisk() macro for DFA
71 <CS27> 11/16/97 djb LockMappingTable is now defined in UnicodeConverterPriv.i.
72 <CS26> 11/13/97 djb Move CatalogIterator struct to CatalogPrivate.h. Include
73 UnicodeConverter.i instead of Unicode.i.
74 <CS25> 11/3/97 JL #2001483 - changed UnMountVolume's prototype.
75 <24> 10/31/97 DSH Added consistencyStatus parameter to MountCheck.
76 <CS23> 10/21/97 DSH Interfacer tweak
77 <CS22> 10/21/97 DSH Conditionalize LMGetFCBTable, LMGetFSVars for DFA to call
78 through DFAs LowMem accessors.
79 <CS21> 10/20/97 msd Add a bytesMaximum parameter to BlockAllocate; removed fcb
81 <CS20> 10/19/97 msd Bug 1684586. Remove the modifyDate field from CatalogNodeDate.
82 GetCatInfo and SetCatInfo use only contentModDate.
83 <CS19> 10/16/97 djb Add LMGetFSVars and LMGetFCBTable macros, add gBlockCacheDirty
84 to FSVars, simplified HFS Stack swapping macros.
85 <CS18> 10/13/97 DSH Added InitBTreeHeader prototype
86 <CS17> 10/13/97 djb Add volumeNameEncodingHint to VCB, add textEncoding to
87 CatalogNodeData, add gTextEncodingFontName to FSVars.
88 <CS16> 10/1/97 DSH Added CheckVolumeConsistency() for 1682475.
89 <CS15> 10/1/97 djb New Catalog iterators and Catalog node cache SPI.
90 <CS14> 9/17/97 DSH Moved prototype HFSBlocksFromTotalSectors() here for DFA
91 wrapperless volume support.
92 <CS13> 9/16/97 msd Add a field to FSVarsRec to store old WriteXParam address.
93 <CS12> 9/15/97 djb Add gBootPToUTable to FSVars (used to bootstrap Unicode).
94 <CS11> 9/7/97 djb Add FlushBlockCache prototype.
95 <CS10> 9/4/97 djb Add cmParentNotFound error code and reportMissingParent bit.
96 <CS9> 9/4/97 msd Remove unused attributes calls. Rename PropertyCloseVolume to
97 AttributesCloseVolume. In CatalogNodeData, replace
98 attributeModDate with modifyDate. Remove macro LatestModDate.
99 <CS8> 8/22/97 djb Add readFromDisk flag to GetCacheBlock and BlockCameFromDisk
101 <CS7> 8/18/97 DSH Override ASM cache accessing routines for DFA to use DFA cache.
102 <CS6> 7/28/97 msd Add prototypes for CacheReadInPlace, RemountWrappedVolumes.
103 <CS5> 7/25/97 DSH Added GenericMRUCache Routines
104 <CS4> 7/22/97 msd In CatalogNodeData, move attributeModDate after backupDate; this
105 allows SetCatInfo to manipulate the rest of the dates in one
106 block, the same as in the parameter block.
107 <CS3> 7/21/97 djb Add more instrumentation globals (CallProfile). Reallign FSVars.
108 <CS2> 7/18/97 msd Selector for PBCreateAttribute conflicts with PBGetXCatInfo. The
109 attribute calls now have selectors in the range $65..$69.
110 <CS1> 7/16/97 DSH first checked in
111 <CS23> 7/8/97 DSH Added LockMappingTable() until its moved into the Unicode header
113 <CS22> 7/7/97 DSH Taking out changes made in HFS <45> for greater compatability
114 with the Tempo installer.
115 <CS21> 6/27/97 msd Add PBLongRename SPI. Add prototype for
116 RenameCatalogNodeUnicode.
117 <CS20> 6/26/97 DSH Conditionalized macro LocalToUTC to not look at FSVars for DFA.
118 <CS19> 6/25/97 msd Add prototype for HFSCommunicationProc.
119 <CS18> 6/24/97 DSH Adding runtime flags to deturmine unicode usage and installation
121 <CS17> 6/24/97 djb Add linkCount to CatalogNodeData. Add LinkCatalogNode prototype.
122 Move Private Catalog Manager prototypes to CatalogPrivate.h.
123 <CS16> 6/20/97 msd Add prototype for CopyCatalogNodeData. In CatalogNodeData,
124 replaced modifyDate with contentModDate and attributeModDate.
125 Added a LatestModDate macro.
126 <15> 6/18/97 djb Add mask to ConversionContext. Add encodingsBitmap to VCB (and
127 reallign some fields). Add gInstalledEncodings to FSVars.
128 <CS14> 6/17/97 msd The conversions between local time and UTC have the sign of the
130 <CS13> 6/13/97 djb Removed PrepareOutputName. Changed parameters for
131 DeleteCatalogNode, MoveCatalogNode, PrepareInputName. Add
132 private catalog macros.
133 <CS12> 6/12/97 msd Export BlockAllocateAny and UpdateVCBFreeBlks.
134 <CS11> 6/12/97 msd Add a parameter block and prototype for an SPI to create very
136 <CS10> 6/9/97 msd Add an offsetToUTC field to FSVarsRec. Add prototypes for
137 GetTimeUTC and GetTimeLocal; add macros for LocalToUTC and
139 <CS9> 6/5/97 msd Add MapLogicalToPhysical (internal routine), PBMapFilePosition
141 <CS8> 6/4/97 djb More Unicode converter changes (support for non roman scripts).
142 <CS7> 6/2/97 msd Add prototype for AdjustEOF.
143 <CS6> 5/28/97 msd Add prototypes for attributes SPI, both internal routines and PB
144 calls. Add FindFileNameGlueRec and FindFileName routine.
145 Prototypes for FindFileControlBlock and AccessBTree disappeared,
147 <CS5> 5/20/97 DSH Including LowMemPriv.a in DFA compiles
148 <CS4> 5/19/97 djb Add uppLockMappingTable to FSVars.
149 <CS3> 5/19/97 djb Add CreateVolumeCatalogCache and DisposeVolumeCatalogCache
150 prototypes. Remove private CatalogDataCache structure.
151 <CS2> 5/16/97 msd Use fixed-size integers for GetBlock_glue and RelBlock_glue so
152 it will build with compilers other than MPW C and SC. Add
153 prototype for FillHFSStack, UnMountVolume, and
154 MakeVCBsExtendedVCBs from VolumeRequests.c. Add prototypes for
155 CreateEmbeddedVolume and InitUnicodeConverter.
156 <CS1> 5/9/97 djb first checked in
157 <CS2> 5/7/97 djb Add summary trace data. Shrink FSVars.later to 4 longs.
158 <CS1> 4/28/97 djb first checked in
161 #ifndef __FILEMGRINTERNAL__
162 #define __FILEMGRINTERNAL__
164 #include <sys/param.h>
165 #include <sys/vnode.h>
167 #include "../../hfs.h"
168 #include "../../hfs_macos_defs.h"
169 #include "../../hfs_format.h"
184 #if PRAGMA_STRUCT_ALIGN
185 #pragma options align=mac68k
186 #elif PRAGMA_STRUCT_PACKPUSH
187 #pragma pack(push, 2)
188 #elif PRAGMA_STRUCT_PACK
192 /* CatalogNodeID is used to track catalog objects */
193 typedef UInt32 HFSCatalogNodeID
;
195 /* internal error codes*/
197 #if TARGET_API_MACOS_X
198 #define ERR_BASE -32767
205 fxRangeErr
= ERR_BASE
+ 16, /* file position beyond mapped range*/
206 fxOvFlErr
= ERR_BASE
+ 17, /* extents file overflow*/
208 uniTooLongErr
= ERR_BASE
+ 24, /* Unicode string too long to convert to Str31*/
209 uniBufferTooSmallErr
= ERR_BASE
+ 25, /* Unicode output buffer too small*/
210 uniNotMappableErr
= ERR_BASE
+ 26, /* Unicode string can't be mapped to given script*/
211 /* BTree Manager errors*/
212 btNotFound
= ERR_BASE
+ 32, /* record not found*/
213 btExists
= ERR_BASE
+ 33, /* record already exists*/
214 btNoSpaceAvail
= ERR_BASE
+ 34, /* no available space*/
215 btNoFit
= ERR_BASE
+ 35, /* record doesn't fit in node */
216 btBadNode
= ERR_BASE
+ 36, /* bad node detected*/
217 btBadHdr
= ERR_BASE
+ 37, /* bad BTree header record detected*/
218 dsBadRotate
= ERR_BASE
+ 64, /* bad BTree rotate*/
219 /* Catalog Manager errors*/
220 cmNotFound
= ERR_BASE
+ 48, /* CNode not found*/
221 cmExists
= ERR_BASE
+ 49, /* CNode already exists*/
222 cmNotEmpty
= ERR_BASE
+ 50, /* directory CNode not empty (valence = 0)*/
223 cmRootCN
= ERR_BASE
+ 51, /* invalid reference to root CNode*/
224 cmBadNews
= ERR_BASE
+ 52, /* detected bad catalog structure*/
225 cmFThdDirErr
= ERR_BASE
+ 53, /* thread belongs to a directory not a file*/
226 cmFThdGone
= ERR_BASE
+ 54, /* file thread doesn't exist*/
227 cmParentNotFound
= ERR_BASE
+ 55, /* CNode for parent ID does not exist*/
228 /* TFS internal errors*/
229 fsDSIntErr
= -127 /* Internal file system error*/
237 /* File System busy flag:*/
238 /* Bit zero of FSBusy (lomem $360) is true when the file system is running.*/
239 /* The word at $360 is cleared when the file system is exited. The*/
240 /* bits defined here are for additional flags in the FSBusy word that are*/
241 /* valid only when the file system is running.*/
242 fsBusyBit
= 0, /* file system is running; other FSBusy bits are valid*/
243 fsSCSIDefer
= 1, /* file system is waiting for SCSI transaction to complete*/
244 fsIntMaskDefer
= 2, /* file system is waiting until the interrupt mask is lowered*/
245 /* Flag bits in HFSFlags byte:*/
246 hfsReq
= 0, /* Set if request is specific to HFS*/
247 dirCN
= 1, /* Set if a CNode is a directory*/
248 reportMissingParent
= 4, /* tell Catalog to report missing parents (used by MakeFSSpec)*/
249 skipPMSP
= 5, /* Set to skip PMSP setup (one-shot)*/
250 noPMSP
= 6, /* Set to disable PMSP completely (status flag)*/
251 hfsContd
= 7, /* Set if Async trap is continued*/
254 fsNoAllocateMask
= 0x01, /* true when allocating memory is a very bad idea*/
256 fsNeedFCBsMask
= 0x02, /* true when a local FCB couldn't be found */
257 fsNoFCBExpansion
= 2,
258 fsNoFCBExpansionMask
= 0x04, /* true if no FCB expansion logic is desired*/
259 /* ExtendFile option flags*/
260 /* extendFileAllBit = 0, |* allocate all requested bytes or none *|*/
261 /* extendFileAllMask = 0x0001,*/
263 /* extendFileContigBit = 1, |* force contiguous allocation *|*/
264 /* extendFileContigMask = 0x0002*/
265 kEFContigBit
= 1, /* force contiguous allocation*/
266 kEFContigMask
= 0x02,
267 kEFAllBit
= 0, /* allocate all requested bytes or none*/
268 kEFAllMask
= 0x01, /* TruncateFile option flags*/
269 kTFTrunExtBit
= 0, /* truncate to the extent containing new PEOF*/
274 kUndefinedStrLen
= 0 /* Unknown string length */
278 HFSStkLen
= 1792, /* old stack size (pre HFS Plus)*/
279 kFileSystemStackSlop
= 16, /* additional temporary space*/
280 kFileSystemStackSize
= 16384, /* give us more breathing room*/
281 kFileSystemVersion
= FOUR_CHAR_CODE('2.0A'), /* current file system version*/
282 /* 31744 = $7C00, a nice round number close to*/
283 /* (32767*1000)/1024, which is about the largest */
284 /* free space unsuspecting, decimal-K minded apps*/
285 /* might be expected to handle.*/
287 kMaxHFSAllocationBlocks
= 31744,
288 WDRfnMin
= -32767, /* lowest assigned WD RefNum*/
289 WDRfnMax
= -4096, /* largest possible WDrefnum*/
290 kFirstFileRefnum
= 2, /* smallest FCB refnum*/
295 /* Internal LowMem pointers*/
297 /*\80\80 The following should really be in LowMemPriv.i*/
300 FSCallAsync
= 0x0342, /* ONE BYTE FREE*/
301 NoEject
= 0x034B, /* used by Eject and Offline*/
303 SysBMCPtr
= 0x0378, /* System-wide bitmap cache pointer*/
304 SysCtlCPtr
= 0x0380, /* System-wide control cache pointer*/
305 HFSDSErr
= 0x0392, /* Final gasp - error that caused IOErr.*/
306 LMParamBlock
= 0x03A4, /* LMGetParams() just gives us a copy of it*/
307 FSVarsPtr
= 0x0BB8, /* lomem that points to file system variable block*/
309 HFSStkPtr
= 0x036E, /* Temporary location of HFS Stack pointer*/
310 FSIOErr
= 0x03DE, /* last I/O error (NEXT WORD FREE)*/
311 /* file manager vectors not found in LowMemPriv.i*/
312 JUpdAltMDB
= (0xED) * 4 + 0x0400, /* ($A0ED) $0400 is n/OSTable*/
313 JCkExtFS
= (0xEE) * 4 + 0x0400, /* ($A0EE) $0400 is n/OSTable*/
314 JBMChk
= (0xF0) * 4 + 0x0400, /* ($A0F0) $0400 is n/OSTable*/
315 JTstMod
= (0xF1) * 4 + 0x0400, /* ($A0F1) $0400 is n/OSTable*/
316 JLocCRec
= (0xF2) * 4 + 0x0400, /* ($A0F2) $0400 is n/OSTable*/
317 JTreeSearch
= (0xF3) * 4 + 0x0400, /* ($A0F3) $0400 is n/OSTable*/
318 JMapFBlock
= (0xF4) * 4 + 0x0400, /* ($A0F4) $0400 is n/OSTable*/
319 JXFSearch
= (0xF5) * 4 + 0x0400, /* ($A0F5) $0400 is n/OSTable*/
320 JReadBM
= (0xF6) * 4 + 0x0400 /* ($A0F6) $0400 is n/OSTable*/
324 /* Poor Man's Search Path*/
326 struct SearchPathHeader
{
327 Ptr PMSPHook
; /* Hook for PMSP modification*/
328 short PMSPIndx
; /* Index to PMSP index from start of PMSP*/
330 typedef struct SearchPathHeader SearchPathHeader
;
332 struct SearchPathEntry
{
333 short spVRefNum
; /* VRefNum in PMSP entry*/
334 UInt32 spDirID
; /* Directory ID in PMSP entry*/
336 typedef struct SearchPathEntry SearchPathEntry
;
340 kPoorMansSearchIndex
= -2,
341 MaxDVCnt
= 8, /* Leave room for 8 default VRefNums*/
342 PMSPSize
= MaxDVCnt
* sizeof(SearchPathEntry
) + sizeof(SearchPathHeader
) + 2
348 fsWDCBExtendCount
= 8, /* # of WDCB's to add when we run out*/
349 /* FileIDs variables*/
350 kNumExtentsToCache
= 4 /* just guessing for ExchangeFiles*/
355 kInvalidMRUCacheKey
= -1L, /* flag to denote current MRU cache key is invalid*/
356 kDefaultNumMRUCacheBlocks
= 16 /* default number of blocks in each cache*/
360 /* Universal Extent Key */
364 HFSPlusExtentKey hfsPlus
;
366 typedef union ExtentKey ExtentKey
;
367 /* Universal extent descriptor */
369 union ExtentDescriptor
{
370 HFSExtentDescriptor hfs
;
371 HFSPlusExtentDescriptor hfsPlus
;
373 typedef union ExtentDescriptor ExtentDescriptor
;
374 /* Universal extent record */
378 HFSPlusExtentRecord hfsPlus
;
380 typedef union ExtentRecord ExtentRecord
;
381 /* Universal catalog key */
385 HFSPlusCatalogKey hfsPlus
;
387 typedef union CatalogKey CatalogKey
;
388 /* Universal catalog data record */
390 union CatalogRecord
{
392 HFSCatalogFolder hfsFolder
;
393 HFSCatalogFile hfsFile
;
394 HFSCatalogThread hfsThread
;
395 HFSPlusCatalogFolder hfsPlusFolder
;
396 HFSPlusCatalogFile hfsPlusFile
;
397 HFSPlusCatalogThread hfsPlusThread
;
399 typedef union CatalogRecord CatalogRecord
;
403 CMMaxCName
= kHFSMaxFileNameChars
408 vcbMaxNam
= 27, /* volumes currently have a 27 byte max name length*/
410 vcbManualEjectMask
= 0x0001, /* bit 0 manual-eject bit: set if volume is in a manual-eject drive*/
411 vcbFlushCriticalInfoMask
= 0x0002, /* bit 1 critical info bit: set if critical MDB information needs to flush*/
412 /* IoParam->ioVAtrb*/
413 kDefaultVolumeMask
= 0x0020,
414 kFilesOpenMask
= 0x0040
418 /* Catalog Node Data - universal data returned from the Catalog Manager*/
422 xFFFilAttrLockMask
= 0x70
425 /* valence is overloaded for files and used as additional flags. 2201501*/
428 kLargeDataForkMask
= 0x00000001,
429 kLargeRsrcForkMask
= 0x00000002
432 /* Universal catalog name*/
438 typedef union CatalogName CatalogName
;
440 /* Unicode Conversion*/
444 kMacBaseEncodingCount
= 50,
445 kTextEncodingUndefined
= 0x00007FFF
448 struct ConversionContext
{
449 TextToUnicodeInfo toUnicode
;
450 UnicodeToTextInfo fromUnicode
;
452 typedef struct ConversionContext ConversionContext
;
461 UInt64 startBase
; /* in nanoseconds*/
463 typedef struct CallProfile CallProfile
;
467 UInt32 gDefaultBaseEncoding
;
468 ItemCount gInstalledEncodings
;
469 ConversionContext gConversionContext
[50];
470 Ptr gBootPToUTable
; /* used by boot code to find Extensions folder*/
471 StringPtr gTextEncodingFontName
; /* points to font name (only used when no HFS Plus volumes have been mounted)*/
472 Boolean gUseDynamicUnicodeConverters
;
473 Boolean gIsUnicodeInstalled
;
475 typedef struct FSVarsRec FSVarsRec
;
480 * MacOS accessor routines
482 #define GetFileControlBlock(fref) ((FCB *)((fref)->v_data))
483 #define GetFileRefNumFromFCB(filePtr) ((filePtr)->h_vp)
486 EXTERN_API_C( Boolean
)
487 BlockCameFromDisk (void);
489 /* The following macro marks a VCB as dirty by setting the upper 8 bits of the flags*/
491 MarkVCBDirty (ExtendedVCB
*vcb
);
494 MarkVCBClean (ExtendedVCB
*vcb
);
496 EXTERN_API_C( Boolean
)
497 IsVCBDirty (ExtendedVCB
*vcb
);
500 #define VCB_LOCK_INIT(vcb) simple_lock_init(&vcb->vcbSimpleLock)
501 #define VCB_LOCK(vcb) simple_lock(&vcb->vcbSimpleLock)
502 #define VCB_UNLOCK(vcb) simple_unlock(&vcb->vcbSimpleLock)
504 #define MarkVCBDirty(vcb) { VCB_LOCK((vcb)); ((vcb)->vcbFlags |= 0xFF00); VCB_UNLOCK((vcb)); }
505 #define MarkVCBClean(vcb) { VCB_LOCK((vcb)); ((vcb)->vcbFlags &= 0x00FF); VCB_UNLOCK((vcb)); }
506 #define IsVCBDirty(vcb) ((Boolean) ((vcb->vcbFlags & 0xFF00) != 0))
509 /* Test for error and return if error occurred*/
511 ReturnIfError (OSErr result
);
513 #define ReturnIfError(result) if ( (result) != noErr ) return (result); else ;
514 /* Test for passed condition and return if true*/
516 ReturnErrorIf (Boolean condition
,
519 #define ReturnErrorIf(condition, error) if ( (condition) ) return( (error) );
520 /* Exit function on error*/
522 ExitOnError (OSErr result
);
524 #define ExitOnError( result ) if ( ( result ) != noErr ) goto ErrorExit; else ;
525 /* Return the low 16 bits of a 32 bit value, pinned if too large*/
526 EXTERN_API_C( UInt16
)
527 LongToShort (UInt32 l
);
529 #define LongToShort( l ) l <= (UInt32)0x0000FFFF ? ((UInt16) l) : ((UInt16) 0xFFFF)
532 /* Catalog Manager Routines (IPI)*/
534 EXTERN_API_C( OSErr
)
535 CreateCatalogNode (ExtendedVCB
* volume
,
536 HFSCatalogNodeID parentID
,
539 HFSCatalogNodeID
* catalogNodeID
,
540 UInt32
* catalogHint
);
542 EXTERN_API_C( OSErr
)
543 DeleteCatalogNode (ExtendedVCB
* volume
,
544 HFSCatalogNodeID parentID
,
548 EXTERN_API_C( OSErr
)
549 GetCatalogNode (ExtendedVCB
* volume
,
550 HFSCatalogNodeID parentID
,
554 CatalogNodeData
* nodeData
,
557 EXTERN_API_C( OSErr
)
558 GetCatalogOffspring (ExtendedVCB
* volume
,
559 HFSCatalogNodeID folderID
,
561 CatalogNodeData
* nodeData
,
562 HFSCatalogNodeID
* nodeID
,
565 EXTERN_API_C( OSErr
)
566 MoveRenameCatalogNode (ExtendedVCB
* volume
,
567 HFSCatalogNodeID srcParentID
,
568 ConstUTF8Param srcName
,
570 HFSCatalogNodeID dstParentID
,
571 ConstUTF8Param dstName
,
574 EXTERN_API_C( OSErr
)
575 UpdateCatalogNode (ExtendedVCB
* volume
,
576 HFSCatalogNodeID parentID
,
579 const CatalogNodeData
* nodeData
);
581 EXTERN_API_C( OSErr
)
582 CreateFileIDRef (ExtendedVCB
* volume
,
583 HFSCatalogNodeID parentID
,
586 HFSCatalogNodeID
* threadID
);
588 EXTERN_API_C( OSErr
)
589 ExchangeFileIDs (ExtendedVCB
* volume
,
590 ConstUTF8Param srcName
,
591 ConstUTF8Param destName
,
592 HFSCatalogNodeID srcID
,
593 HFSCatalogNodeID destID
,
597 EXTERN_API_C( OSErr
)
598 LinkCatalogNode (ExtendedVCB
* volume
,
599 HFSCatalogNodeID parentID
,
601 HFSCatalogNodeID linkParentID
,
602 ConstUTF8Param linkName
);
604 EXTERN_API_C( SInt32
)
605 CompareCatalogKeys (HFSCatalogKey
* searchKey
,
606 HFSCatalogKey
* trialKey
);
608 EXTERN_API_C( SInt32
)
609 CompareExtendedCatalogKeys (HFSPlusCatalogKey
* searchKey
,
610 HFSPlusCatalogKey
* trialKey
);
612 EXTERN_API_C( OSErr
)
613 InitCatalogCache (void);
616 InvalidateCatalogCache (ExtendedVCB
* volume
);
619 /* GenericMRUCache Routines*/
620 EXTERN_API_C( OSErr
)
621 InitMRUCache (UInt32 bufferSize
,
622 UInt32 numCacheBlocks
,
625 EXTERN_API_C( OSErr
)
626 DisposeMRUCache (Ptr cachePtr
);
629 TrashMRUCache (Ptr cachePtr
);
631 EXTERN_API_C( OSErr
)
632 GetMRUCacheBlock (UInt32 key
,
637 InvalidateMRUCacheBlock (Ptr cachePtr
,
641 InsertMRUCacheBlock (Ptr cachePtr
,
645 /* BTree Manager Routines*/
647 typedef CALLBACK_API_C( SInt32
, KeyCompareProcPtr
)(void *a
, void *b
);
650 EXTERN_API_C( OSErr
)
651 SearchBTreeRecord (FileReference refNum
,
659 EXTERN_API_C( OSErr
)
660 InsertBTreeRecord (FileReference refNum
,
666 EXTERN_API_C( OSErr
)
667 DeleteBTreeRecord (FileReference refNum
,
670 EXTERN_API_C( OSErr
)
671 ReplaceBTreeRecord (FileReference refNum
,
678 /* From HFSVolumesInit.c*/
680 InitBTreeHeader (UInt32 fileSize
,
689 /* Prototypes for big block cache*/
691 EXTERN_API_C( OSErr
)
692 InitializeBlockCache (UInt32 blockSize
,
695 EXTERN_API_C( OSErr
)
696 FlushBlockCache (void);
698 EXTERN_API_C( OSErr
)
699 GetCacheBlock (FileReference fileRefNum
,
703 LogicalAddress
* buffer
,
704 Boolean
* readFromDisk
);
706 EXTERN_API_C( OSErr
)
707 ReleaseCacheBlock (LogicalAddress buffer
,
710 EXTERN_API_C( OSErr
)
711 MarkCacheBlock (LogicalAddress buffer
);
713 EXTERN_API_C( OSErr
)
714 TrashCacheBlocks (FileReference fileRefNum
);
716 /* Prototypes for C->Asm glue*/
717 EXTERN_API_C( OSErr
)
718 GetBlock_glue (UInt16 flags
,
721 FileReference refNum
,
724 EXTERN_API_C( OSErr
)
725 RelBlock_glue (Ptr nodeBuffer
,
729 MarkBlock_glue (Ptr nodeBuffer
);
731 EXTERN_API_C( OSErr
)
732 C_FlushCache (ExtendedVCB
* vcb
,
734 FileReference refNum
);
737 EXTERN_API_C( void ) TrashVolumeDiskCache(ExtendedVCB
* vcb
);
739 /* Prototypes for exported routines in VolumeAllocation.c*/
740 EXTERN_API_C( OSErr
)
741 BlockAllocate (ExtendedVCB
* vcb
,
742 UInt32 startingBlock
,
743 SInt64 bytesRequested
,
745 Boolean forceContiguous
,
747 UInt32
* actualBlocks
);
749 EXTERN_API_C( OSErr
)
750 BlockDeallocate (ExtendedVCB
* vcb
,
754 EXTERN_API_C( OSErr
)
755 UpdateFreeCount (ExtendedVCB
* vcb
);
758 EXTERN_API_C( OSErr
)
759 AllocateFreeSpace (ExtendedVCB
* vcb
,
761 UInt32
* actualBlocks
);
763 EXTERN_API_C( UInt32
)
764 FileBytesToBlocks (SInt64 numerator
,
767 EXTERN_API_C( OSErr
)
768 BlockAllocateAny (ExtendedVCB
* vcb
,
769 UInt32 startingBlock
,
772 UInt32
* actualStartBlock
,
773 UInt32
* actualNumBlocks
);
776 UpdateVCBFreeBlks (ExtendedVCB
* vcb
);
778 /* File Extent Mapping routines*/
779 EXTERN_API_C( OSErr
)
780 FlushExtentFile (ExtendedVCB
* vcb
);
782 EXTERN_API_C( SInt32
)
783 CompareExtentKeys (const HFSExtentKey
* searchKey
,
784 const HFSExtentKey
* trialKey
);
786 EXTERN_API_C( SInt32
)
787 CompareExtentKeysPlus (const HFSPlusExtentKey
*searchKey
,
788 const HFSPlusExtentKey
*trialKey
);
790 EXTERN_API_C( OSErr
)
791 DeleteFile (ExtendedVCB
* vcb
,
792 HFSCatalogNodeID parDirID
,
793 ConstUTF8Param catalogName
,
796 EXTERN_API_C( OSErr
)
797 TruncateFileC (ExtendedVCB
* vcb
,
800 Boolean truncateToExtent
);
802 EXTERN_API_C( OSErr
)
803 ExtendFileC (ExtendedVCB
* vcb
,
807 SInt64
* actualBytesAdded
);
809 EXTERN_API_C( OSErr
)
810 MapFileBlockC (ExtendedVCB
* vcb
,
812 size_t numberOfBytes
,
814 daddr_t
* startBlock
,
815 size_t * availableBytes
);
817 #if TARGET_API_MACOS_X
818 EXTERN_API_C( Boolean
)
819 NodesAreContiguous (ExtendedVCB
* vcb
,
824 AdjustEOF (FCB
* sourceFCB
);
826 /* Utility routines*/
829 ClearMemory (void * start
,
832 EXTERN_API_C( Boolean
)
833 UnicodeBinaryCompare (ConstHFSUniStr255Param ustr1
,
834 ConstHFSUniStr255Param ustr2
);
836 EXTERN_API_C( Boolean
)
837 PascalBinaryCompare (ConstStr31Param pstr1
,
838 ConstStr31Param pstr2
);
840 EXTERN_API_C( OSErr
)
841 VolumeWritable (ExtendedVCB
* vcb
);
844 /* Get the current time in UTC (GMT)*/
845 EXTERN_API_C( UInt32
)
848 /* Get the current local time*/
849 EXTERN_API_C( UInt32
)
850 GetTimeLocal (Boolean forHFS
);
852 EXTERN_API_C( UInt32
)
853 LocalToUTC (UInt32 localTime
);
855 EXTERN_API_C( UInt32
)
856 UTCToLocal (UInt32 utcTime
);
859 /* Volumes routines*/
860 EXTERN_API_C( OSErr
)
861 FlushVolumeControlBlock (ExtendedVCB
* vcb
);
863 EXTERN_API_C( OSErr
)
864 CheckVolumeOffLine (ExtendedVCB
* vcb
);
866 EXTERN_API_C( OSErr
)
867 ValidVolumeHeader (HFSPlusVolumeHeader
* volumeHeader
);
873 EXTERN_API_C( OSErr
)
874 AccessBTree (ExtendedVCB
* vcb
,
875 FileReference refNum
,
877 UInt32 fileClumpSize
,
878 void * CompareRoutine
);
881 RemountWrappedVolumes (void);
883 EXTERN_API_C( OSErr
)
884 CheckVolumeConsistency (ExtendedVCB
* vcb
);
887 HFSBlocksFromTotalSectors (UInt32 totalSectors
,
889 UInt16
* blockCount
);
894 #if PRAGMA_STRUCT_ALIGN
895 #pragma options align=reset
896 #elif PRAGMA_STRUCT_PACKPUSH
898 #elif PRAGMA_STRUCT_PACK
902 #ifdef PRAGMA_IMPORT_OFF
912 #endif /* __FILEMGRINTERNAL__ */