X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/d52fe63fc81f7e44faaae711812a211a78434976..9bccf70c0258c7cac2dcb80011b2a964d884c552:/bsd/hfs/hfscommon/Catalog/FileIDsServices.c diff --git a/bsd/hfs/hfscommon/Catalog/FileIDsServices.c b/bsd/hfs/hfscommon/Catalog/FileIDsServices.c index 43cdd2a22..923e90334 100644 --- a/bsd/hfs/hfscommon/Catalog/FileIDsServices.c +++ b/bsd/hfs/hfscommon/Catalog/FileIDsServices.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -19,106 +19,6 @@ * * @APPLE_LICENSE_HEADER_END@ */ -/* - File: FileIDServices.c - - Contains: File ID manipulating routines. - - Version: HFS Plus 1.0 - - Written by: Deric Horn - - Copyright: © 1996-1999 by Apple Computer, Inc., all rights reserved. - - File Ownership: - - DRI: Deric Horn - - Other Contact: xxx put other contact here xxx - - Technology: xxx put technology here xxx - - Writers: - - (JL) Jim Luther - (msd) Mark Day - (djb) Don Brady - (DSH) Deric Horn - - Change History (most recent first): - 3/2/98 djb Fix extents corruption bug in MoveExtents (radar #2309434). - 11/20/98 djb Add support for UTF-8 names. - 4/2/98 djb Switch over to real BTree interface in MoveExtents and DeleteExtents. - 3/31/98 djb Sync up with final HFSVolumes.h header file. - - 11/17/97 djb PrepareInputName routine now returns an error. - 11/13/97 djb Radar #2001699 ResolveFileID needs to use CMNotFound error. - 10/31/97 JL #2000184 - CreateFileThreadID and ExchangeFiles now return the - WDCBRecPtr or NULL for external file systems. ExchangeFiles no - longer returns length of FCB table to caller since that wasn't - ever needed. - <18> 10/23/97 DSH 1685058, Fix ExchangeFiles by invalidating the node cache before - switching the files. - 10/19/97 msd Bug 1684586. GetCatInfo and SetCatInfo use only contentModDate. - 10/16/97 DSH Return badFidErr in ResolveFileID if LocateCatalogThread fails - 10/15/97 DSH CreateFileThreadID(), remap btExists to fidExists. - 9/7/97 djb Turn off some DebugStr calls. - 9/4/97 msd Remove call to PropertyExchangeObjects. - 8/14/97 djb Remove hard link support. - 7/18/97 msd Include LowMemPriv.h. - 7/16/97 DSH FilesInternal.i renamed FileMgrInternal.i to avoid name - collision - 7/8/97 DSH Loading PrecompiledHeaders from define passed in on C line - 6/24/97 djb Add hard link support to ResolveFileID and CreateFileIDRef. - 6/20/97 msd Use contentModDate and attributeModDate fields instead of - modifyDate. - 6/13/97 djb Switch over from PrepareOutputName to ConvertUnicodeToHFSName. - PrepareInputName now takes an encoding. - 5/28/97 msd Move the declaration of FindFileName to FilesInternal.i. - 5/19/97 djb No longer need to invalidate vcbDirIDM field. - 5/16/97 msd In ExchangeFiles, change srcNamePtr from char * to StringPtr - (fixes warnings). - 4/28/97 djb (DSH) Added VolumeWritable check back into CreateFileIDThread. - 4/24/97 djb first checked in - 4/11/97 DSH Use extended VCB fields catalogRefNum, and extentsRefNum. - 4/9/97 msd Rewrite CreateFileThreadID so that it properly handles - pathnames, and doesn't overwrite the ioNamePtr. The data field - of FindFileNameGlueRec points to a CatalogNodeData, not - CatalogRecord. - 4/4/97 djb Get in sync with volume format changes. - 3/31/97 djb Change ClearMem to ClearMemory. - 3/17/97 DSH C_FlushCache prototype to FilesInternal.h - 3/5/97 msd ExchangeFiles needs to call PropertyExchangeObjects. - 2/13/97 msd Fix MoveExtents and DeleteExtents to work with HFS+ extent - records. - 1/31/97 msd In MoveExtents, when a record isn't found and you want the next - record in order, use the "next record" offset = 1 instead of - "current record" offset = 0. DeleteExtents would always exit - without doing anything because it was searching for an invalid - key. Removed several DebugStrs that were used as cheap code - coverage. - 1/15/97 DSH Resolve wasn't passing the name back for HFS - 1/13/97 djb LocateCatalogThread now passes back the thread record size. - 1/11/97 DSH HFS+, fixed some Unicode/Pascal strings related bugs for use on - HFS+ volumes. - 1/9/97 DSH Fix ExchangeFiles extents - 1/6/97 DSH pass VCB in CloseFile() routine. - 1/6/97 djb Fixed ResolveFileID - it was not returning a directory ID! - 1/3/97 msd Fix prototype for C_FlushCache. Fix prototype for - TrashFileBlocks. - 1/3/97 djb Integrate latest HFSVolumesPriv.h changes. - 1/2/97 DSH C port of ExchangeFileIDs - 12/20/96 djb Fixed bug in CreateFileID. - 12/19/96 DSH All refs to VCB are now refs to ExtendedVCB - 12/19/96 msd Use kFileThreadExistsMask (from HFSVolumesPriv.h) instead of - kFileThreadMask (from FilesInternal.h) since the latter was - incorrectly defined and has now been removed. - 12/19/96 djb Updated for new B-tree Manager interface. - 12/18/96 msd GetFileThreadID was using a bitwise-OR (|) instead of - bitwise-AND (&) to test for a bit being set. - 12/12/96 DSH first checked in - -*/ #include "../../hfs_macos_defs.h" #include "../../hfs_format.h" @@ -129,37 +29,32 @@ struct ExtentsRecBuffer { - ExtentKey extentKey; + ExtentKey extentKey; ExtentRecord extentData; }; typedef struct ExtentsRecBuffer ExtentsRecBuffer; -OSErr CreateFileID( ExtendedVCB *vcb, HFSCatalogNodeID fileID, CatalogName *name, HFSCatalogNodeID *threadID ); -OSErr GetFileThreadID( ExtendedVCB *vcb, HFSCatalogNodeID id, const CatalogName *name, Boolean isHFSPlus, UInt32 *threadID ); - UInt32 CheckExtents( void *extents, UInt32 blocks, Boolean isHFSPlus ); OSErr DeleteExtents( ExtendedVCB *vcb, UInt32 fileNumber, Boolean isHFSPlus ); OSErr MoveExtents( ExtendedVCB *vcb, UInt32 srcFileID, UInt32 destFileID, Boolean isHFSPlus ); void CopyCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); void CopyBigCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); - void CopyExtentInfo( ExtentKey *key, ExtentRecord *data, ExtentsRecBuffer *buffer, UInt16 bufferCount ); -extern void TrashFileBlocks( ExtendedVCB *vcb, UInt32 fileNumber ); OSErr ExchangeFileIDs( ExtendedVCB *vcb, ConstUTF8Param srcName, ConstUTF8Param destName, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, UInt32 srcHint, UInt32 destHint ) { - CatalogKey srcKey; // 518 bytes + CatalogKey srcKey; // 518 bytes + CatalogKey destKey; // 518 bytes CatalogRecord srcData; // 520 bytes - CatalogKey destKey; // 518 bytes CatalogRecord destData; // 520 bytes CatalogRecord swapData; // 520 bytes - SInt16 numSrcExtentBlocks; - SInt16 numDestExtentBlocks; - OSErr err; - Boolean isHFSPlus = ( vcb->vcbSigWord == kHFSPlusSigWord ); + SInt16 numSrcExtentBlocks; + SInt16 numDestExtentBlocks; + OSErr err; + Boolean isHFSPlus = ( vcb->vcbSigWord == kHFSPlusSigWord ); TrashCatalogIterator(vcb, srcID); // invalidate any iterators for this parentID TrashCatalogIterator(vcb, destID); // invalidate any iterators for this parentID @@ -458,10 +353,8 @@ FlushAndReturn: void CopyCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ) { -// dest->hfsFile.filStBlk = src->hfsFile.filStBlk; dest->hfsFile.dataLogicalSize = src->hfsFile.dataLogicalSize; dest->hfsFile.dataPhysicalSize = src->hfsFile.dataPhysicalSize; -// dest->hfsFile.filRStBlk = src->hfsFile.filRStBlk; dest->hfsFile.rsrcLogicalSize = src->hfsFile.rsrcLogicalSize; dest->hfsFile.rsrcPhysicalSize = src->hfsFile.rsrcPhysicalSize; dest->hfsFile.modifyDate = src->hfsFile.modifyDate; @@ -545,7 +438,7 @@ OSErr MoveExtents( ExtendedVCB *vcb, UInt32 srcFileID, UInt32 destFileID, Boolea // we found, so that BTIterateRecord would get the next one (the first we haven't processed). // - err = BTSearchRecord(fcb, &btIterator, kInvalidMRUCacheKey, &btRecord, &btRecordSize, &btIterator); + err = BTSearchRecord(fcb, &btIterator, &btRecord, &btRecordSize, &btIterator); // We expect a btNotFound here, since there shouldn't be an extent record with FABN = 0. if (err != btNotFound) @@ -682,7 +575,7 @@ OSErr DeleteExtents( ExtendedVCB *vcb, UInt32 fileID, Boolean isHFSPlus ) extentKeyPtr->hfs.startBlock = 0; } - err = BTSearchRecord(fcb, &btIterator, kInvalidMRUCacheKey, &btRecord, &btRecordSize, &btIterator); + err = BTSearchRecord(fcb, &btIterator, &btRecord, &btRecordSize, &btIterator); if ( err != btNotFound ) { if (err == noErr) { // Did we find a bogus extent record?