]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b | 27 | */ |
1c79356b A |
28 | |
29 | #include "../../hfs_macos_defs.h" | |
30 | #include "../../hfs_format.h" | |
31 | ||
32 | #include "../headers/FileMgrInternal.h" | |
33 | #include "../headers/HFSUnicodeWrappers.h" | |
34 | #include "../headers/CatalogPrivate.h" | |
35 | ||
36 | ||
37 | struct ExtentsRecBuffer { | |
9bccf70c | 38 | ExtentKey extentKey; |
1c79356b A |
39 | ExtentRecord extentData; |
40 | }; | |
41 | typedef struct ExtentsRecBuffer ExtentsRecBuffer; | |
42 | ||
43 | ||
2d21ac55 A |
44 | static u_int32_t CheckExtents( void *extents, u_int32_t blocks, Boolean isHFSPlus ); |
45 | static OSErr DeleteExtents( ExtendedVCB *vcb, u_int32_t fileNumber, Boolean isHFSPlus ); | |
46 | static OSErr MoveExtents( ExtendedVCB *vcb, u_int32_t srcFileID, u_int32_t destFileID, Boolean isHFSPlus ); | |
91447636 A |
47 | static void CopyCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); |
48 | static void CopyBigCatalogNodeInfo( CatalogRecord *src, CatalogRecord *dest ); | |
2d21ac55 | 49 | static void CopyExtentInfo( ExtentKey *key, ExtentRecord *data, ExtentsRecBuffer *buffer, u_int16_t bufferCount ); |
1c79356b A |
50 | |
51 | ||
52 | ||
2d21ac55 | 53 | OSErr ExchangeFileIDs( ExtendedVCB *vcb, ConstUTF8Param srcName, ConstUTF8Param destName, HFSCatalogNodeID srcID, HFSCatalogNodeID destID, u_int32_t srcHint, u_int32_t destHint ) |
1c79356b | 54 | { |
9bccf70c A |
55 | CatalogKey srcKey; // 518 bytes |
56 | CatalogKey destKey; // 518 bytes | |
1c79356b | 57 | CatalogRecord srcData; // 520 bytes |
1c79356b A |
58 | CatalogRecord destData; // 520 bytes |
59 | CatalogRecord swapData; // 520 bytes | |
2d21ac55 A |
60 | int16_t numSrcExtentBlocks; |
61 | int16_t numDestExtentBlocks; | |
9bccf70c A |
62 | OSErr err; |
63 | Boolean isHFSPlus = ( vcb->vcbSigWord == kHFSPlusSigWord ); | |
1c79356b | 64 | |
0b4e3aa0 | 65 | err = BuildCatalogKeyUTF8(vcb, srcID, srcName, kUndefinedStrLen, &srcKey, NULL); |
1c79356b A |
66 | ReturnIfError(err); |
67 | ||
0b4e3aa0 | 68 | err = BuildCatalogKeyUTF8(vcb, destID, destName, kUndefinedStrLen, &destKey, NULL); |
1c79356b A |
69 | ReturnIfError(err); |
70 | ||
71 | if ( isHFSPlus ) | |
72 | { | |
73 | //-- Step 1: Check the catalog nodes for extents | |
74 | ||
75 | //-- locate the source file, test for extents in extent file, and copy the cat record for later | |
76 | err = LocateCatalogNodeByKey( vcb, srcHint, &srcKey, &srcData, &srcHint ); | |
77 | ReturnIfError( err ); | |
78 | ||
79 | if ( srcData.recordType != kHFSPlusFileRecord ) | |
80 | return( cmFThdDirErr ); // Error "cmFThdDirErr = it is a directory" | |
81 | ||
82 | //-- Check if there are any extents in the source file | |
83 |