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@
26 * This file implements endian swapping routines for the HFS/HFS Plus
30 #include <architecture/byte_order.h>
32 #include "hfs_endian.h"
37 /* Private swapping routines */
38 int hfs_swap_HFSPlusBTInternalNode (BlockDescriptor
*src
, HFSCatalogNodeID fileID
, int unswap
);
39 int hfs_swap_HFSBTInternalNode (BlockDescriptor
*src
, HFSCatalogNodeID fileID
, int unswap
);
42 * hfs_swap_HFSPlusForkData
44 * There's still a few spots where we still need to swap the fork data.
47 hfs_swap_HFSPlusForkData (
53 src
->logicalSize
= SWAP_BE64 (src
->logicalSize
);
55 src
->clumpSize
= SWAP_BE32 (src
->clumpSize
);
56 src
->totalBlocks
= SWAP_BE32 (src
->totalBlocks
);
58 for (i
= 0; i
< kHFSPlusExtentDensity
; i
++) {
59 src
->extents
[i
].startBlock
= SWAP_BE32 (src
->extents
[i
].startBlock
);
60 src
->extents
[i
].blockCount
= SWAP_BE32 (src
->extents
[i
].blockCount
);
67 * NOTE: This operation is not naturally symmetric.
68 * We have to determine which way we're swapping things.
74 HFSCatalogNodeID fileID
,
78 BTNodeDescriptor
*srcDesc
= src
->buffer
;
79 UInt16
*srcOffs
= NULL
;
87 printf ("BE -> LE Swap\n");
88 } else if (unswap
== 1) {
89 printf ("LE -> BE Swap\n");
90 } else if (unswap
== 3) {
91 printf ("Not swapping descriptors\n");
93 panic ("%s This is impossible", "hfs_swap_BTNode:");
97 /* If we are doing a swap */
99 /* Swap the node descriptor */
100 srcDesc
->fLink
= SWAP_BE32 (srcDesc
->fLink
);
101 srcDesc
->bLink
= SWAP_BE32 (srcDesc
->bLink
);
103 /* Don't swap srcDesc->kind */
104 /* Don't swap srcDesc->height */
105 /* Don't swap srcDesc->reserved */
107 srcDesc
->numRecords
= SWAP_BE16 (srcDesc
->numRecords
);
109 /* Swap the node offsets (including the free space one!) */
110 srcOffs
= (UInt16
*)((char *)src
->buffer
+ (src
->blockSize
- ((srcDesc
->numRecords
+ 1) * sizeof (UInt16
))));
113 if ((char *)srcOffs
> ((char *)src
->buffer
+ src
->blockSize
)) {
114 panic ("%s Too many records in the B-Tree node", "hfs_swap_BTNode:");
117 for (i
= 0; i
< srcDesc
->numRecords
+ 1; i
++) {
118 srcOffs
[i
] = SWAP_BE16 (srcOffs
[i
]);
121 if (srcOffs
[i
] >= src
->blockSize
) {
122 panic ("%s B-Tree node offset out of range", "hfs_swap_BTNode:");
127 /* Swap the records (ordered by frequency of access) */
128 /* Swap a B-Tree internal node */
129 if ((srcDesc
->kind
== kBTIndexNode
) ||
130 (srcDesc
-> kind
== kBTLeafNode
)) {
133 error
= hfs_swap_HFSPlusBTInternalNode (src
, fileID
, unswap
);
135 error
= hfs_swap_HFSBTInternalNode (src
, fileID
, unswap
);
138 /* Swap a B-Tree map node */
139 } else if (srcDesc
-> kind
== kBTMapNode
) {
140 /* Don't swap the bitmaps, they'll be done in the bitmap routines */
142 /* Swap a B-Tree header node */
143 } else if (srcDesc
-> kind
== kBTHeaderNode
) {
144 /* The header's offset is hard-wired because we cannot trust the offset pointers */
145 BTHeaderRec
*srcHead
= (BTHeaderRec
*)((char *)src
->buffer
+ 14);
147 srcHead
->treeDepth
= SWAP_BE16 (srcHead
->treeDepth
);
149 srcHead
->rootNode
= SWAP_BE32 (srcHead
->rootNode
);
150 srcHead
->leafRecords
= SWAP_BE32 (srcHead
->leafRecords
);
151 srcHead
->firstLeafNode
= SWAP_BE32 (srcHead
->firstLeafNode
);
152 srcHead
->lastLeafNode
= SWAP_BE32 (srcHead
->lastLeafNode
);
154 srcHead
->nodeSize
= SWAP_BE16 (srcHead
->nodeSize
);
155 srcHead
->maxKeyLength
= SWAP_BE16 (srcHead
->maxKeyLength
);
157 srcHead
->totalNodes
= SWAP_BE32 (srcHead
->totalNodes
);
158 srcHead
->freeNodes
= SWAP_BE32 (srcHead
->freeNodes
);
160 srcHead
->clumpSize
= SWAP_BE32 (srcHead
->clumpSize
);
161 srcHead
->attributes
= SWAP_BE32 (srcHead
->attributes
);
163 /* Don't swap srcHead->reserved1 */
164 /* Don't swap srcHead->btreeType */
165 /* Don't swap srcHead->reserved2 */
166 /* Don't swap srcHead->reserved3 */
167 /* Don't swap bitmap */
170 /* If we are doing an unswap */
172 /* Swap the node descriptor */
173 srcDesc
->fLink
= SWAP_BE32 (srcDesc
->fLink
);
174 srcDesc
->bLink
= SWAP_BE32 (srcDesc
->bLink
);
176 /* Don't swap srcDesc->kind */
177 /* Don't swap srcDesc->height */
178 /* Don't swap srcDesc->reserved */
180 /* Swap the node offsets (including the free space one!) */
181 srcOffs
= (UInt16
*)((char *)src
->buffer
+ (src
->blockSize
- ((srcDesc
->numRecords
+ 1) * sizeof (UInt16
))));
184 if ((char *)srcOffs
> ((char *)src
->buffer
+ src
->blockSize
)) {
185 panic ("%s Too many records in the B-Tree node", "hfs_swap_BTNode:");
188 for (i
= 0; i
< srcDesc
->numRecords
+ 1; i
++) {
190 if (srcOffs
[i
] >= src
->blockSize
) {
191 panic ("%s B-Tree node offset out of range", "hfs_swap_BTNode:");
194 srcOffs
[i
] = SWAP_BE16 (srcOffs
[i
]);
197 srcDesc
->numRecords
= SWAP_BE16 (srcDesc
->numRecords
);
204 hfs_swap_HFSPlusBTInternalNode (
205 BlockDescriptor
*src
,
206 HFSCatalogNodeID fileID
,
210 BTNodeDescriptor
*srcDesc
= src
->buffer
;
211 UInt16
*srcOffs
= (UInt16
*)((char *)src
->buffer
+ (src
->blockSize
- (srcDesc
->numRecords
* sizeof (UInt16
))));
216 if (fileID
== kHFSExtentsFileID
) {
217 HFSPlusExtentKey
*srcKey
;
218 HFSPlusExtentDescriptor
*srcRec
;
220 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
221 srcKey
= (HFSPlusExtentKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
223 if (!unswap
) srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
224 srcRec
= (HFSPlusExtentDescriptor
*)((char *)srcKey
+ srcKey
->keyLength
+ 2);
225 if (unswap
) srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
227 /* Don't swap srcKey->forkType */
228 /* Don't swap srcKey->pad */
230 srcKey
->fileID
= SWAP_BE32 (srcKey
->fileID
);
231 srcKey
->startBlock
= SWAP_BE32 (srcKey
->startBlock
);
233 /* Stop if this is just an index node */
234 if (srcDesc
->kind
== kBTIndexNode
) {
235 *((UInt32
*)srcRec
) = SWAP_BE32 (*((UInt32
*)srcRec
));
239 /* Swap the extent data */
241 /* Swap each extent */
242 for (j
= 0; j
< kHFSPlusExtentDensity
; j
++) {
243 srcRec
[j
].startBlock
= SWAP_BE32 (srcRec
[j
].startBlock
);
244 srcRec
[j
].blockCount
= SWAP_BE32 (srcRec
[j
].blockCount
);
248 } else if (fileID
== kHFSCatalogFileID
) {
249 HFSPlusCatalogKey
*srcKey
;
252 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
253 srcKey
= (HFSPlusCatalogKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
255 if (!unswap
) srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
256 srcPtr
= (SInt16
*)((char *)srcKey
+ srcKey
->keyLength
+ 2);
257 if (unswap
) srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
259 srcKey
->parentID
= SWAP_BE32 (srcKey
->parentID
);
261 if (!unswap
) srcKey
->nodeName
.length
= SWAP_BE16 (srcKey
->nodeName
.length
);
262 for (j
= 0; j
< srcKey
->nodeName
.length
; j
++) {
263 srcKey
->nodeName
.unicode
[j
] = SWAP_BE16 (srcKey
->nodeName
.unicode
[j
]);
265 if (unswap
) srcKey
->nodeName
.length
= SWAP_BE16 (srcKey
->nodeName
.length
);
267 /* Stop if this is just an index node */
268 if (srcDesc
->kind
== kBTIndexNode
) {
269 *((UInt32
*)srcPtr
) = SWAP_BE32 (*((UInt32
*)srcPtr
));
273 /* Swap the recordType field, if unswapping, leave to later */
274 if (!unswap
) srcPtr
[0] = SWAP_BE16 (srcPtr
[0]);
276 if (srcPtr
[0] == kHFSPlusFolderRecord
) {
277 HFSPlusCatalogFolder
*srcRec
= (HFSPlusCatalogFolder
*)srcPtr
;
279 srcRec
->flags
= SWAP_BE16 (srcRec
->flags
);
280 srcRec
->valence
= SWAP_BE32 (srcRec
->valence
);
281 srcRec
->folderID
= SWAP_BE32 (srcRec
->folderID
);
282 srcRec
->createDate
= SWAP_BE32 (srcRec
->createDate
);
283 srcRec
->contentModDate
= SWAP_BE32 (srcRec
->contentModDate
);
284 srcRec
->attributeModDate
= SWAP_BE32 (srcRec
->attributeModDate
);
285 srcRec
->accessDate
= SWAP_BE32 (srcRec
->accessDate
);
286 srcRec
->backupDate
= SWAP_BE32 (srcRec
->backupDate
);
288 srcRec
->bsdInfo
.ownerID
= SWAP_BE32 (srcRec
->bsdInfo
.ownerID
);
289 srcRec
->bsdInfo
.groupID
= SWAP_BE32 (srcRec
->bsdInfo
.groupID
);
291 /* Don't swap srcRec->bsdInfo.adminFlags */
292 /* Don't swap srcRec->bsdInfo.ownerFlags */
294 srcRec
->bsdInfo
.fileMode
= SWAP_BE16 (srcRec
->bsdInfo
.fileMode
);
295 srcRec
->bsdInfo
.special
.iNodeNum
= SWAP_BE32 (srcRec
->bsdInfo
.special
.iNodeNum
);
297 srcRec
->textEncoding
= SWAP_BE32 (srcRec
->textEncoding
);
299 /* Don't swap srcRec->userInfo */
300 /* Don't swap srcRec->finderInfo */
301 /* Don't swap srcRec->reserved */
303 } else if (srcPtr
[0] == kHFSPlusFileRecord
) {
304 HFSPlusCatalogFile
*srcRec
= (HFSPlusCatalogFile
*)srcPtr
;
306 srcRec
->flags
= SWAP_BE16 (srcRec
->flags
);
308 srcRec
->fileID
= SWAP_BE32 (srcRec
->fileID
);
310 srcRec
->createDate
= SWAP_BE32 (srcRec
->createDate
);
311 srcRec
->contentModDate
= SWAP_BE32 (srcRec
->contentModDate
);
312 srcRec
->attributeModDate
= SWAP_BE32 (srcRec
->attributeModDate
);
313 srcRec
->accessDate
= SWAP_BE32 (srcRec
->accessDate
);
314 srcRec
->backupDate
= SWAP_BE32 (srcRec
->backupDate
);
316 srcRec
->bsdInfo
.ownerID
= SWAP_BE32 (srcRec
->bsdInfo
.ownerID
);
317 srcRec
->bsdInfo
.groupID
= SWAP_BE32 (srcRec
->bsdInfo
.groupID
);
319 /* Don't swap srcRec->bsdInfo.adminFlags */
320 /* Don't swap srcRec->bsdInfo.ownerFlags */
322 srcRec
->bsdInfo
.fileMode
= SWAP_BE16 (srcRec
->bsdInfo
.fileMode
);
323 srcRec
->bsdInfo
.special
.iNodeNum
= SWAP_BE32 (srcRec
->bsdInfo
.special
.iNodeNum
);
325 srcRec
->textEncoding
= SWAP_BE32 (srcRec
->textEncoding
);
327 /* Don't swap srcRec->reserved1 */
328 /* Don't swap srcRec->userInfo */
329 /* Don't swap srcRec->finderInfo */
330 /* Don't swap srcRec->reserved2 */
332 hfs_swap_HFSPlusForkData (&srcRec
->dataFork
);
333 hfs_swap_HFSPlusForkData (&srcRec
->resourceFork
);
335 } else if ((srcPtr
[0] == kHFSPlusFolderThreadRecord
) ||
336 (srcPtr
[0] == kHFSPlusFileThreadRecord
)) {
338 HFSPlusCatalogThread
*srcRec
= (HFSPlusCatalogThread
*)srcPtr
;
340 /* Don't swap srcRec->reserved */
342 srcRec
->parentID
= SWAP_BE32 (srcRec
->parentID
);
344 if (!unswap
) srcRec
->nodeName
.length
= SWAP_BE16 (srcRec
->nodeName
.length
);
345 for (j
= 0; j
< srcRec
->nodeName
.length
; j
++) {
346 srcRec
->nodeName
.unicode
[j
] = SWAP_BE16 (srcRec
->nodeName
.unicode
[j
]);
348 if (unswap
) srcRec
->nodeName
.length
= SWAP_BE16 (srcRec
->nodeName
.length
);
351 panic ("%s unrecognized catalog record type", "hfs_swap_BTNode:");
354 /* If unswapping, we can safely unswap type field now */
355 if (unswap
) srcPtr
[0] = SWAP_BE16 (srcPtr
[0]);
358 } else if (fileID
== kHFSAttributesFileID
) {
359 HFSPlusAttrKey
*srcKey
;
360 HFSPlusAttrRecord
*srcRec
;
362 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
363 srcKey
= (HFSPlusAttrKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
365 if (!unswap
) srcKey
->keyLength
= SWAP_BE16(srcKey
->keyLength
);
366 srcRec
= (HFSPlusAttrRecord
*)((char *)srcKey
+ srcKey
->keyLength
+ 2);
367 if (unswap
) srcKey
->keyLength
= SWAP_BE16(srcKey
->keyLength
);
369 srcKey
->fileID
= SWAP_BE32(srcKey
->fileID
);
370 srcKey
->startBlock
= SWAP_BE32(srcKey
->startBlock
);
372 if (!unswap
) srcKey
->attrNameLen
= SWAP_BE16(srcKey
->attrNameLen
);
373 for (j
= 0; j
< srcKey
->attrNameLen
; j
++)
374 srcKey
->attrName
[j
] = SWAP_BE16(srcKey
->attrName
[j
]);
375 if (unswap
) srcKey
->attrNameLen
= SWAP_BE16(srcKey
->attrNameLen
);
377 /* If this is an index node, just swap the child node number */
378 if (srcDesc
->kind
== kBTIndexNode
) {
379 *((UInt32
*)srcRec
) = SWAP_BE32 (*((UInt32
*)srcRec
));
383 /* Swap the data record */
384 if (!unswap
) srcRec
->recordType
= SWAP_BE32(srcRec
->recordType
);
385 switch (srcRec
->recordType
) {
386 case kHFSPlusAttrInlineData
:
387 /* We're not swapping the reserved fields */
388 srcRec
->attrData
.attrSize
= SWAP_BE32(srcRec
->attrData
.attrSize
);
389 /* Not swapping the attrData */
391 case kHFSPlusAttrForkData
:
392 /* We're not swapping the reserved field */
393 hfs_swap_HFSPlusForkData(&srcRec
->forkData
.theFork
);
395 case kHFSPlusAttrExtents
:
396 /* We're not swapping the reserved field */
397 for (j
= 0; j
< kHFSPlusExtentDensity
; j
++) {
398 srcRec
->overflowExtents
.extents
[j
].startBlock
=
399 SWAP_BE32(srcRec
->overflowExtents
.extents
[j
].startBlock
);
400 srcRec
->overflowExtents
.extents
[j
].blockCount
=
401 SWAP_BE32(srcRec
->overflowExtents
.extents
[j
].blockCount
);
405 if (unswap
) srcRec
->recordType
= SWAP_BE32(srcRec
->recordType
);
407 } else if (fileID
> kHFSFirstUserCatalogNodeID
) {
411 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
412 srcKey
= (HotFileKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
415 srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
416 srcRec
= (u_int32_t
*)((char *)srcKey
+ srcKey
->keyLength
+ 2);
418 srcKey
->keyLength
= SWAP_BE16 (srcKey
->keyLength
);
420 /* Don't swap srcKey->forkType */
421 /* Don't swap srcKey->pad */
423 srcKey
->temperature
= SWAP_BE32 (srcKey
->temperature
);
424 srcKey
->fileID
= SWAP_BE32 (srcKey
->fileID
);
426 *((UInt32
*)srcRec
) = SWAP_BE32 (*((UInt32
*)srcRec
));
429 panic ("%s unrecognized B-Tree type", "hfs_swap_BTNode:");
437 hfs_swap_HFSBTInternalNode (
438 BlockDescriptor
*src
,
439 HFSCatalogNodeID fileID
,
443 BTNodeDescriptor
*srcDesc
= src
->buffer
;
444 UInt16
*srcOffs
= (UInt16
*)((char *)src
->buffer
+ (src
->blockSize
- (srcDesc
->numRecords
* sizeof (UInt16
))));
449 if (fileID
== kHFSExtentsFileID
) {
450 HFSExtentKey
*srcKey
;
451 HFSExtentDescriptor
*srcRec
;
453 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
454 srcKey
= (HFSExtentKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
456 /* Don't swap srcKey->keyLength */
457 /* Don't swap srcKey->forkType */
459 srcKey
->fileID
= SWAP_BE32 (srcKey
->fileID
);
460 srcKey
->startBlock
= SWAP_BE16 (srcKey
->startBlock
);
462 /* Point to record data (round up to even byte boundary) */
463 srcRec
= (HFSExtentDescriptor
*)((char *)srcKey
+ ((srcKey
->keyLength
+ 2) & ~1));
465 /* Stop if this is just an index node */
466 if (srcDesc
->kind
== kBTIndexNode
) {
467 *((UInt32
*)srcRec
) = SWAP_BE32 (*((UInt32
*)srcRec
));
471 /* Swap each extent */
472 for (j
= 0; j
< kHFSExtentDensity
; j
++) {
473 srcRec
[j
].startBlock
= SWAP_BE16 (srcRec
[j
].startBlock
);
474 srcRec
[j
].blockCount
= SWAP_BE16 (srcRec
[j
].blockCount
);
478 } else if (fileID
== kHFSCatalogFileID
) {
479 HFSCatalogKey
*srcKey
;
482 for (i
= 0; i
< srcDesc
->numRecords
; i
++) {
483 srcKey
= (HFSCatalogKey
*)((char *)src
->buffer
+ srcOffs
[i
]);
485 /* Don't swap srcKey->keyLength */
486 /* Don't swap srcKey->reserved */
488 srcKey
->parentID
= SWAP_BE32 (srcKey
->parentID
);
490 /* Don't swap srcKey->nodeName */
492 /* Point to record data (round up to even byte boundary) */
493 srcPtr
= (SInt16
*)((char *)srcKey
+ ((srcKey
->keyLength
+ 2) & ~1));
495 /* Stop if this is just an index node */
496 if (srcDesc
->kind
== kBTIndexNode
) {
497 *((UInt32
*)srcPtr
) = SWAP_BE32 (*((UInt32
*)srcPtr
));
501 /* Swap the recordType field, if unswapping, leave to later */
502 if (!unswap
) srcPtr
[0] = SWAP_BE16 (srcPtr
[0]);
504 if (srcPtr
[0] == kHFSFolderRecord
) {
505 HFSCatalogFolder
*srcRec
= (HFSCatalogFolder
*)srcPtr
;
507 srcRec
->flags
= SWAP_BE16 (srcRec
->flags
);
508 srcRec
->valence
= SWAP_BE16 (srcRec
->valence
);
510 srcRec
->folderID
= SWAP_BE32 (srcRec
->folderID
);
511 srcRec
->createDate
= SWAP_BE32 (srcRec
->createDate
);
512 srcRec
->modifyDate
= SWAP_BE32 (srcRec
->modifyDate
);
513 srcRec
->backupDate
= SWAP_BE32 (srcRec
->backupDate
);
515 /* Don't swap srcRec->userInfo */
516 /* Don't swap srcRec->finderInfo */
517 /* Don't swap resserved array */
519 } else if (srcPtr
[0] == kHFSFileRecord
) {
520 HFSCatalogFile
*srcRec
= (HFSCatalogFile
*)srcPtr
;
522 srcRec
->flags
= srcRec
->flags
;
523 srcRec
->fileType
= srcRec
->fileType
;
525 /* Don't swap srcRec->userInfo */
527 srcRec
->fileID
= SWAP_BE32 (srcRec
->fileID
);
529 srcRec
->dataStartBlock
= SWAP_BE16 (srcRec
->dataStartBlock
);
530 srcRec
->dataLogicalSize
= SWAP_BE32 (srcRec
->dataLogicalSize
);
531 srcRec
->dataPhysicalSize
= SWAP_BE32 (srcRec
->dataPhysicalSize
);
533 srcRec
->rsrcStartBlock
= SWAP_BE16 (srcRec
->rsrcStartBlock
);
534 srcRec
->rsrcLogicalSize
= SWAP_BE32 (srcRec
->rsrcLogicalSize
);
535 srcRec
->rsrcPhysicalSize
= SWAP_BE32 (srcRec
->rsrcPhysicalSize
);
537 srcRec
->createDate
= SWAP_BE32 (srcRec
->createDate
);
538 srcRec
->modifyDate
= SWAP_BE32 (srcRec
->modifyDate
);
539 srcRec
->backupDate
= SWAP_BE32 (srcRec
->backupDate
);
541 /* Don't swap srcRec->finderInfo */
543 srcRec
->clumpSize
= SWAP_BE16 (srcRec
->clumpSize
);
545 /* Swap the two sets of extents as an array of six (three each) UInt16 */
546 for (j
= 0; j
< kHFSExtentDensity
* 2; j
++) {
547 srcRec
->dataExtents
[j
].startBlock
= SWAP_BE16 (srcRec
->dataExtents
[j
].startBlock
);
548 srcRec
->dataExtents
[j
].blockCount
= SWAP_BE16 (srcRec
->dataExtents
[j
].blockCount
);
551 /* Don't swap srcRec->reserved */
553 } else if ((srcPtr
[0] == kHFSFolderThreadRecord
) ||
554 (srcPtr
[0] == kHFSFileThreadRecord
)) {
556 HFSCatalogThread
*srcRec
= (HFSCatalogThread
*)srcPtr
;
558 /* Don't swap srcRec->reserved array */
560 srcRec
->parentID
= SWAP_BE32 (srcRec
->parentID
);
562 /* Don't swap srcRec->nodeName */
565 panic ("%s unrecognized catalog record type", "hfs_swap_BTNode:");
568 /* If unswapping, we can safely swap type now */
569 if (unswap
) srcPtr
[0] = SWAP_BE16 (srcPtr
[0]);
573 panic ("%s unrecognized B-Tree type", "hfs_swap_BTNode:");