|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 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: FilesInternal.h ! 24: ! 25: Contains: IPI for File Manager (HFS Plus) ! 26: ! 27: Version: HFS Plus 1.0 ! 28: ! 29: Copyright: � 1996-1999 by Apple Computer, Inc., all rights reserved. ! 30: ! 31: File Ownership: ! 32: ! 33: DRI: Don Brady ! 34: ! 35: Other Contacts: Mark Day, Deric horn, Jim Luther ! 36: ! 37: Technology: File Systems ! 38: ! 39: Writers: ! 40: ! 41: (JL) Jim Luther ! 42: (msd) Mark Day ! 43: (djb) Don Brady ! 44: (DSH) Deric Horn ! 45: ! 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. ! 65: ! 66: <CS30> 1/29/98 DSH Added TrashVolumeDiskCache prototype for TrashAllFSCaches API ! 67: support. ! 68: <CS29> 12/10/97 DSH 2201501, Overload the NodeData valence field for over 2 Gig file ! 69: support. ! 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 ! 80: parameter. ! 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 ! 100: macro. ! 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 ! 112: files. ! 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 ! 120: status. ! 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 ! 129: offset backwards. ! 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 ! 135: large files. ! 136: <CS10> 6/9/97 msd Add an offsetToUTC field to FSVarsRec. Add prototypes for ! 137: GetTimeUTC and GetTimeLocal; add macros for LocalToUTC and ! 138: UTCToLocal. ! 139: <CS9> 6/5/97 msd Add MapLogicalToPhysical (internal routine), PBMapFilePosition ! 140: for external use. ! 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, ! 146: so added again. ! 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 ! 159: ! 160: */ ! 161: #ifndef __FILEMGRINTERNAL__ ! 162: #define __FILEMGRINTERNAL__ ! 163: ! 164: #include <sys/param.h> ! 165: #include <sys/vnode.h> ! 166: ! 167: #include "../../hfs.h" ! 168: #include "../../hfs_macos_defs.h" ! 169: #include "../../hfs_format.h" ! 170: ! 171: ! 172: #if PRAGMA_ONCE ! 173: #pragma once ! 174: #endif ! 175: ! 176: #ifdef __cplusplus ! 177: extern "C" { ! 178: #endif ! 179: ! 180: #if PRAGMA_IMPORT ! 181: #pragma import on ! 182: #endif ! 183: ! 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 ! 189: #pragma pack(2) ! 190: #endif ! 191: ! 192: /* CatalogNodeID is used to track catalog objects */ ! 193: typedef UInt32 HFSCatalogNodeID; ! 194: ! 195: /* internal error codes*/ ! 196: ! 197: #if TARGET_API_MACOS_X ! 198: #define ERR_BASE -32767 ! 199: #else ! 200: #define ERR_BASE 0 ! 201: #endif ! 202: ! 203: enum { ! 204: /* FXM errors*/ ! 205: fxRangeErr = ERR_BASE + 16, /* file position beyond mapped range*/ ! 206: fxOvFlErr = ERR_BASE + 17, /* extents file overflow*/ ! 207: /* Unicode errors*/ ! 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*/ ! 230: }; ! 231: ! 232: ! 233: /* internal flags*/ ! 234: ! 235: ! 236: enum { ! 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*/ ! 252: /* fsFlags values*/ ! 253: fsNoAllocate = 0, ! 254: fsNoAllocateMask = 0x01, /* true when allocating memory is a very bad idea*/ ! 255: fsNeedFCBs = 1, ! 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,*/ ! 262: /* */ ! 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*/ ! 270: kTFTrunExtMask = 1 ! 271: }; ! 272: ! 273: enum { ! 274: kUndefinedStrLen = 0 /* Unknown string length */ ! 275: }; ! 276: ! 277: enum { ! 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.*/ ! 286: /* AlBlkLim*/ ! 287: kMaxHFSAllocationBlocks = 31744, ! 288: WDRfnMin = -32767, /* lowest assigned WD RefNum*/ ! 289: WDRfnMax = -4096, /* largest possible WDrefnum*/ ! 290: kFirstFileRefnum = 2, /* smallest FCB refnum*/ ! 291: kNoHint = 0 ! 292: }; ! 293: ! 294: ! 295: /* Internal LowMem pointers*/ ! 296: ! 297: /*�� The following should really be in LowMemPriv.i*/ ! 298: ! 299: enum { ! 300: FSCallAsync = 0x0342, /* ONE BYTE FREE*/ ! 301: NoEject = 0x034B, /* used by Eject and Offline*/ ! 302: CacheFlag = 0x0377, ! 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*/ ! 308: CacheVars = 0x0394, ! 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*/ ! 321: }; ! 322: ! 323: ! 324: /* Poor Man's Search Path*/ ! 325: ! 326: struct SearchPathHeader { ! 327: Ptr PMSPHook; /* Hook for PMSP modification*/ ! 328: short PMSPIndx; /* Index to PMSP index from start of PMSP*/ ! 329: }; ! 330: typedef struct SearchPathHeader SearchPathHeader; ! 331: ! 332: struct SearchPathEntry { ! 333: short spVRefNum; /* VRefNum in PMSP entry*/ ! 334: UInt32 spDirID; /* Directory ID in PMSP entry*/ ! 335: }; ! 336: typedef struct SearchPathEntry SearchPathEntry; ! 337: ! 338: ! 339: enum { ! 340: kPoorMansSearchIndex = -2, ! 341: MaxDVCnt = 8, /* Leave room for 8 default VRefNums*/ ! 342: PMSPSize = MaxDVCnt * sizeof(SearchPathEntry) + sizeof(SearchPathHeader) + 2 ! 343: }; ! 344: ! 345: ! 346: ! 347: enum { ! 348: fsWDCBExtendCount = 8, /* # of WDCB's to add when we run out*/ ! 349: /* FileIDs variables*/ ! 350: kNumExtentsToCache = 4 /* just guessing for ExchangeFiles*/ ! 351: }; ! 352: ! 353: ! 354: enum { ! 355: kInvalidMRUCacheKey = -1L, /* flag to denote current MRU cache key is invalid*/ ! 356: kDefaultNumMRUCacheBlocks = 16 /* default number of blocks in each cache*/ ! 357: }; ! 358: ! 359: ! 360: /* Universal Extent Key */ ! 361: ! 362: union ExtentKey { ! 363: HFSExtentKey hfs; ! 364: HFSPlusExtentKey hfsPlus; ! 365: }; ! 366: typedef union ExtentKey ExtentKey; ! 367: /* Universal extent descriptor */ ! 368: ! 369: union ExtentDescriptor { ! 370: HFSExtentDescriptor hfs; ! 371: HFSPlusExtentDescriptor hfsPlus; ! 372: }; ! 373: typedef union ExtentDescriptor ExtentDescriptor; ! 374: /* Universal extent record */ ! 375: ! 376: union ExtentRecord { ! 377: HFSExtentRecord hfs; ! 378: HFSPlusExtentRecord hfsPlus; ! 379: }; ! 380: typedef union ExtentRecord ExtentRecord; ! 381: /* Universal catalog key */ ! 382: ! 383: union CatalogKey { ! 384: HFSCatalogKey hfs; ! 385: HFSPlusCatalogKey hfsPlus; ! 386: }; ! 387: typedef union CatalogKey CatalogKey; ! 388: /* Universal catalog data record */ ! 389: ! 390: union CatalogRecord { ! 391: SInt16 recordType; ! 392: HFSCatalogFolder hfsFolder; ! 393: HFSCatalogFile hfsFile; ! 394: HFSCatalogThread hfsThread; ! 395: HFSPlusCatalogFolder hfsPlusFolder; ! 396: HFSPlusCatalogFile hfsPlusFile; ! 397: HFSPlusCatalogThread hfsPlusThread; ! 398: }; ! 399: typedef union CatalogRecord CatalogRecord; ! 400: ! 401: ! 402: enum { ! 403: CMMaxCName = kHFSMaxFileNameChars ! 404: }; ! 405: ! 406: ! 407: enum { ! 408: vcbMaxNam = 27, /* volumes currently have a 27 byte max name length*/ ! 409: /* VCB flags*/ ! 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 ! 415: }; ! 416: ! 417: ! 418: /* Catalog Node Data - universal data returned from the Catalog Manager*/ ! 419: ! 420: ! 421: enum { ! 422: xFFFilAttrLockMask = 0x70 ! 423: }; ! 424: ! 425: /* valence is overloaded for files and used as additional flags. 2201501*/ ! 426: ! 427: enum { ! 428: kLargeDataForkMask = 0x00000001, ! 429: kLargeRsrcForkMask = 0x00000002 ! 430: }; ! 431: ! 432: /* Universal catalog name*/ ! 433: ! 434: union CatalogName { ! 435: Str31 pstr; ! 436: HFSUniStr255 ustr; ! 437: }; ! 438: typedef union CatalogName CatalogName; ! 439: ! 440: /* Unicode Conversion*/ ! 441: ! 442: ! 443: enum { ! 444: kMacBaseEncodingCount = 50, ! 445: kTextEncodingUndefined = 0x00007FFF ! 446: }; ! 447: ! 448: struct ConversionContext { ! 449: TextToUnicodeInfo toUnicode; ! 450: UnicodeToTextInfo fromUnicode; ! 451: }; ! 452: typedef struct ConversionContext ConversionContext; ! 453: ! 454: struct CallProfile { ! 455: UInt16 refCount; ! 456: UInt16 errCount; ! 457: UInt32 callCount; ! 458: UInt32 minTime; ! 459: UInt32 maxTime; ! 460: UInt64 totalTime; ! 461: UInt64 startBase; /* in nanoseconds*/ ! 462: }; ! 463: typedef struct CallProfile CallProfile; ! 464: ! 465: ! 466: struct FSVarsRec { ! 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; ! 474: }; ! 475: typedef struct FSVarsRec FSVarsRec; ! 476: ! 477: ! 478: ! 479: /* ! 480: * MacOS accessor routines ! 481: */ ! 482: #define GetFileControlBlock(fref) ((FCB *)((fref)->v_data)) ! 483: #define GetFileRefNumFromFCB(filePtr) ((filePtr)->h_vp) ! 484: ! 485: ! 486: EXTERN_API_C( Boolean ) ! 487: BlockCameFromDisk (void); ! 488: ! 489: /* The following macro marks a VCB as dirty by setting the upper 8 bits of the flags*/ ! 490: EXTERN_API_C( void ) ! 491: MarkVCBDirty (ExtendedVCB *vcb); ! 492: ! 493: EXTERN_API_C( void ) ! 494: MarkVCBClean (ExtendedVCB *vcb); ! 495: ! 496: EXTERN_API_C( Boolean ) ! 497: IsVCBDirty (ExtendedVCB *vcb); ! 498: ! 499: ! 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) ! 503: ! 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)) ! 507: ! 508: ! 509: /* Test for error and return if error occurred*/ ! 510: EXTERN_API_C( void ) ! 511: ReturnIfError (OSErr result); ! 512: ! 513: #define ReturnIfError(result) if ( (result) != noErr ) return (result); else ; ! 514: /* Test for passed condition and return if true*/ ! 515: EXTERN_API_C( void ) ! 516: ReturnErrorIf (Boolean condition, ! 517: OSErr result); ! 518: ! 519: #define ReturnErrorIf(condition, error) if ( (condition) ) return( (error) ); ! 520: /* Exit function on error*/ ! 521: EXTERN_API_C( void ) ! 522: ExitOnError (OSErr result); ! 523: ! 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); ! 528: ! 529: #define LongToShort( l ) l <= (UInt32)0x0000FFFF ? ((UInt16) l) : ((UInt16) 0xFFFF) ! 530: ! 531: ! 532: /* Catalog Manager Routines (IPI)*/ ! 533: ! 534: EXTERN_API_C( OSErr ) ! 535: CreateCatalogNode (ExtendedVCB * volume, ! 536: HFSCatalogNodeID parentID, ! 537: ConstUTF8Param name, ! 538: UInt32 nodeType, ! 539: HFSCatalogNodeID * catalogNodeID, ! 540: UInt32 * catalogHint); ! 541: ! 542: EXTERN_API_C( OSErr ) ! 543: DeleteCatalogNode (ExtendedVCB * volume, ! 544: HFSCatalogNodeID parentID, ! 545: ConstUTF8Param name, ! 546: UInt32 hint); ! 547: ! 548: EXTERN_API_C( OSErr ) ! 549: GetCatalogNode (ExtendedVCB * volume, ! 550: HFSCatalogNodeID parentID, ! 551: ConstUTF8Param name, ! 552: UInt32 length, ! 553: UInt32 hint, ! 554: FSSpec * nodeSpec, ! 555: CatalogNodeData * nodeData, ! 556: UInt32 * newHint); ! 557: ! 558: EXTERN_API_C( OSErr ) ! 559: GetCatalogOffspring (ExtendedVCB * volume, ! 560: HFSCatalogNodeID folderID, ! 561: UInt16 index, ! 562: FSSpec * spec, ! 563: CatalogNodeData * nodeData, ! 564: HFSCatalogNodeID * nodeID, ! 565: SInt16 * nodeType); ! 566: ! 567: EXTERN_API_C( OSErr ) ! 568: MoveRenameCatalogNode (ExtendedVCB * volume, ! 569: HFSCatalogNodeID srcParentID, ! 570: ConstUTF8Param srcName, ! 571: UInt32 srcHint, ! 572: HFSCatalogNodeID dstParentID, ! 573: ConstUTF8Param dstName, ! 574: UInt32 * newHint); ! 575: ! 576: EXTERN_API_C( OSErr ) ! 577: UpdateCatalogNode (ExtendedVCB * volume, ! 578: HFSCatalogNodeID parentID, ! 579: ConstUTF8Param name, ! 580: UInt32 catalogHint, ! 581: const CatalogNodeData * nodeData); ! 582: ! 583: EXTERN_API_C( OSErr ) ! 584: CreateFileIDRef (ExtendedVCB * volume, ! 585: HFSCatalogNodeID parentID, ! 586: ConstUTF8Param name, ! 587: UInt32 hint, ! 588: HFSCatalogNodeID * threadID); ! 589: ! 590: EXTERN_API_C( OSErr ) ! 591: ExchangeFileIDs (ExtendedVCB * volume, ! 592: ConstUTF8Param srcName, ! 593: ConstUTF8Param destName, ! 594: HFSCatalogNodeID srcID, ! 595: HFSCatalogNodeID destID, ! 596: UInt32 srcHint, ! 597: UInt32 destHint ); ! 598: ! 599: EXTERN_API_C( OSErr ) ! 600: LinkCatalogNode (ExtendedVCB * volume, ! 601: HFSCatalogNodeID parentID, ! 602: ConstUTF8Param name, ! 603: HFSCatalogNodeID linkParentID, ! 604: ConstUTF8Param linkName); ! 605: ! 606: EXTERN_API_C( SInt32 ) ! 607: CompareCatalogKeys (HFSCatalogKey * searchKey, ! 608: HFSCatalogKey * trialKey); ! 609: ! 610: EXTERN_API_C( SInt32 ) ! 611: CompareExtendedCatalogKeys (HFSPlusCatalogKey * searchKey, ! 612: HFSPlusCatalogKey * trialKey); ! 613: ! 614: EXTERN_API_C( OSErr ) ! 615: InitCatalogCache (void); ! 616: ! 617: EXTERN_API_C( void ) ! 618: InvalidateCatalogCache (ExtendedVCB * volume); ! 619: ! 620: ! 621: /* GenericMRUCache Routines*/ ! 622: EXTERN_API_C( OSErr ) ! 623: InitMRUCache (UInt32 bufferSize, ! 624: UInt32 numCacheBlocks, ! 625: Ptr * cachePtr); ! 626: ! 627: EXTERN_API_C( OSErr ) ! 628: DisposeMRUCache (Ptr cachePtr); ! 629: ! 630: EXTERN_API_C( void ) ! 631: TrashMRUCache (Ptr cachePtr); ! 632: ! 633: EXTERN_API_C( OSErr ) ! 634: GetMRUCacheBlock (UInt32 key, ! 635: Ptr cachePtr, ! 636: Ptr * buffer); ! 637: ! 638: EXTERN_API_C( void ) ! 639: InvalidateMRUCacheBlock (Ptr cachePtr, ! 640: Ptr buffer); ! 641: ! 642: EXTERN_API_C( void ) ! 643: InsertMRUCacheBlock (Ptr cachePtr, ! 644: UInt32 key, ! 645: Ptr buffer); ! 646: ! 647: /* BTree Manager Routines*/ ! 648: ! 649: typedef CALLBACK_API_C( SInt32 , KeyCompareProcPtr )(void *a, void *b); ! 650: ! 651: ! 652: EXTERN_API_C( OSErr ) ! 653: SearchBTreeRecord (FileReference refNum, ! 654: const void * key, ! 655: UInt32 hint, ! 656: void * foundKey, ! 657: void * data, ! 658: UInt16 * dataSize, ! 659: UInt32 * newHint); ! 660: ! 661: EXTERN_API_C( OSErr ) ! 662: InsertBTreeRecord (FileReference refNum, ! 663: void * key, ! 664: void * data, ! 665: UInt16 dataSize, ! 666: UInt32 * newHint); ! 667: ! 668: EXTERN_API_C( OSErr ) ! 669: DeleteBTreeRecord (FileReference refNum, ! 670: void * key); ! 671: ! 672: EXTERN_API_C( OSErr ) ! 673: ReplaceBTreeRecord (FileReference refNum, ! 674: const void * key, ! 675: UInt32 hint, ! 676: void * newData, ! 677: UInt16 dataSize, ! 678: UInt32 * newHint); ! 679: ! 680: /* From HFSVolumesInit.c*/ ! 681: EXTERN_API_C( void ) ! 682: InitBTreeHeader (UInt32 fileSize, ! 683: UInt32 clumpSize, ! 684: UInt16 nodeSize, ! 685: UInt16 recordCount, ! 686: UInt16 keySize, ! 687: UInt32 attributes, ! 688: UInt32 * mapNodes, ! 689: void * buffer); ! 690: ! 691: /* Prototypes for big block cache*/ ! 692: ! 693: EXTERN_API_C( OSErr ) ! 694: InitializeBlockCache (UInt32 blockSize, ! 695: UInt32 blockCount); ! 696: ! 697: EXTERN_API_C( OSErr ) ! 698: FlushBlockCache (void); ! 699: ! 700: EXTERN_API_C( OSErr ) ! 701: GetCacheBlock (FileReference fileRefNum, ! 702: UInt32 blockNumber, ! 703: UInt32 blockSize, ! 704: UInt16 options, ! 705: LogicalAddress * buffer, ! 706: Boolean * readFromDisk); ! 707: ! 708: EXTERN_API_C( OSErr ) ! 709: ReleaseCacheBlock (LogicalAddress buffer, ! 710: UInt16 options); ! 711: ! 712: EXTERN_API_C( OSErr ) ! 713: MarkCacheBlock (LogicalAddress buffer); ! 714: ! 715: EXTERN_API_C( OSErr ) ! 716: TrashCacheBlocks (FileReference fileRefNum); ! 717: ! 718: /* Prototypes for C->Asm glue*/ ! 719: EXTERN_API_C( OSErr ) ! 720: GetBlock_glue (UInt16 flags, ! 721: UInt32 nodeNumber, ! 722: Ptr * nodeBuffer, ! 723: FileReference refNum, ! 724: ExtendedVCB * vcb); ! 725: ! 726: EXTERN_API_C( OSErr ) ! 727: RelBlock_glue (Ptr nodeBuffer, ! 728: UInt16 flags); ! 729: ! 730: EXTERN_API_C( void ) ! 731: MarkBlock_glue (Ptr nodeBuffer); ! 732: ! 733: EXTERN_API_C( OSErr ) ! 734: C_FlushCache (ExtendedVCB * vcb, ! 735: UInt32 flags, ! 736: FileReference refNum); ! 737: ! 738: ! 739: EXTERN_API_C( void ) TrashVolumeDiskCache(ExtendedVCB * vcb); ! 740: ! 741: /* Prototypes for exported routines in VolumeAllocation.c*/ ! 742: EXTERN_API_C( OSErr ) ! 743: BlockAllocate (ExtendedVCB * vcb, ! 744: UInt32 startingBlock, ! 745: SInt64 bytesRequested, ! 746: SInt64 bytesMaximum, ! 747: Boolean forceContiguous, ! 748: UInt32 * startBlock, ! 749: UInt32 * actualBlocks); ! 750: ! 751: EXTERN_API_C( OSErr ) ! 752: BlockDeallocate (ExtendedVCB * vcb, ! 753: UInt32 firstBlock, ! 754: UInt32 numBlocks); ! 755: ! 756: EXTERN_API_C( OSErr ) ! 757: UpdateFreeCount (ExtendedVCB * vcb); ! 758: ! 759: ! 760: EXTERN_API_C( OSErr ) ! 761: AllocateFreeSpace (ExtendedVCB * vcb, ! 762: UInt32 * startBlock, ! 763: UInt32 * actualBlocks); ! 764: ! 765: EXTERN_API_C( UInt32 ) ! 766: FileBytesToBlocks (SInt64 numerator, ! 767: UInt32 denominator); ! 768: ! 769: EXTERN_API_C( OSErr ) ! 770: BlockAllocateAny (ExtendedVCB * vcb, ! 771: UInt32 startingBlock, ! 772: UInt32 endingBlock, ! 773: UInt32 maxBlocks, ! 774: UInt32 * actualStartBlock, ! 775: UInt32 * actualNumBlocks); ! 776: ! 777: EXTERN_API_C( void ) ! 778: UpdateVCBFreeBlks (ExtendedVCB * vcb); ! 779: ! 780: /* File Extent Mapping routines*/ ! 781: EXTERN_API_C( OSErr ) ! 782: FlushExtentFile (ExtendedVCB * vcb); ! 783: ! 784: EXTERN_API_C( SInt32 ) ! 785: CompareExtentKeys (const HFSExtentKey * searchKey, ! 786: const HFSExtentKey * trialKey); ! 787: ! 788: EXTERN_API_C( SInt32 ) ! 789: CompareExtentKeysPlus (const HFSPlusExtentKey *searchKey, ! 790: const HFSPlusExtentKey *trialKey); ! 791: ! 792: EXTERN_API_C( OSErr ) ! 793: DeleteFile (ExtendedVCB * vcb, ! 794: HFSCatalogNodeID parDirID, ! 795: ConstUTF8Param catalogName, ! 796: UInt32 catalogHint); ! 797: ! 798: EXTERN_API_C( OSErr ) ! 799: TruncateFileC (ExtendedVCB * vcb, ! 800: FCB * fcb, ! 801: SInt64 peof, ! 802: Boolean truncateToExtent); ! 803: ! 804: EXTERN_API_C( OSErr ) ! 805: ExtendFileC (ExtendedVCB * vcb, ! 806: FCB * fcb, ! 807: SInt64 bytesToAdd, ! 808: UInt32 flags, ! 809: SInt64 * actualBytesAdded); ! 810: ! 811: EXTERN_API_C( OSErr ) ! 812: MapFileBlockC (ExtendedVCB * vcb, ! 813: FCB * fcb, ! 814: SInt64 numberOfBytes, ! 815: SInt64 offset, ! 816: UInt32 * startBlock, ! 817: UInt32 * availableBytes); ! 818: ! 819: #if TARGET_API_MACOS_X ! 820: EXTERN_API_C( Boolean ) ! 821: NodesAreContiguous (ExtendedVCB * vcb, ! 822: FCB * fcb, ! 823: UInt32 nodeSize); ! 824: #endif ! 825: EXTERN_API_C( void ) ! 826: AdjustEOF (FCB * sourceFCB); ! 827: ! 828: /* Utility routines*/ ! 829: ! 830: EXTERN_API_C( void ) ! 831: ClearMemory (void * start, ! 832: UInt32 length); ! 833: ! 834: EXTERN_API_C( Boolean ) ! 835: UnicodeBinaryCompare (ConstHFSUniStr255Param ustr1, ! 836: ConstHFSUniStr255Param ustr2); ! 837: ! 838: EXTERN_API_C( Boolean ) ! 839: PascalBinaryCompare (ConstStr31Param pstr1, ! 840: ConstStr31Param pstr2); ! 841: ! 842: EXTERN_API_C( OSErr ) ! 843: VolumeWritable (ExtendedVCB * vcb); ! 844: ! 845: ! 846: /* Get the current time in UTC (GMT)*/ ! 847: EXTERN_API_C( UInt32 ) ! 848: GetTimeUTC (void); ! 849: ! 850: /* Get the current local time*/ ! 851: EXTERN_API_C( UInt32 ) ! 852: GetTimeLocal (Boolean forHFS); ! 853: ! 854: EXTERN_API_C( UInt32 ) ! 855: LocalToUTC (UInt32 localTime); ! 856: ! 857: EXTERN_API_C( UInt32 ) ! 858: UTCToLocal (UInt32 utcTime); ! 859: ! 860: ! 861: /* Volumes routines*/ ! 862: EXTERN_API_C( OSErr ) ! 863: FlushVolumeControlBlock (ExtendedVCB * vcb); ! 864: ! 865: EXTERN_API_C( OSErr ) ! 866: CheckVolumeOffLine (ExtendedVCB * vcb); ! 867: ! 868: EXTERN_API_C( OSErr ) ! 869: ValidVolumeHeader (HFSPlusVolumeHeader * volumeHeader); ! 870: ! 871: EXTERN_API_C( void ) ! 872: FillHFSStack (void); ! 873: ! 874: ! 875: EXTERN_API_C( OSErr ) ! 876: AccessBTree (ExtendedVCB * vcb, ! 877: FileReference refNum, ! 878: UInt32 fileID, ! 879: UInt32 fileClumpSize, ! 880: void * CompareRoutine); ! 881: ! 882: EXTERN_API_C( void ) ! 883: RemountWrappedVolumes (void); ! 884: ! 885: EXTERN_API_C( OSErr ) ! 886: CheckVolumeConsistency (ExtendedVCB * vcb); ! 887: ! 888: EXTERN_API_C( void ) ! 889: HFSBlocksFromTotalSectors (UInt32 totalSectors, ! 890: UInt32 * blockSize, ! 891: UInt16 * blockCount); ! 892: ! 893: ! 894: ! 895: ! 896: #if PRAGMA_STRUCT_ALIGN ! 897: #pragma options align=reset ! 898: #elif PRAGMA_STRUCT_PACKPUSH ! 899: #pragma pack(pop) ! 900: #elif PRAGMA_STRUCT_PACK ! 901: #pragma pack() ! 902: #endif ! 903: ! 904: #ifdef PRAGMA_IMPORT_OFF ! 905: #pragma import off ! 906: #elif PRAGMA_IMPORT ! 907: #pragma import reset ! 908: #endif ! 909: ! 910: #ifdef __cplusplus ! 911: } ! 912: #endif ! 913: ! 914: #endif /* __FILEMGRINTERNAL__ */ ! 915:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.