X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/a3d08fcd5120d2aa8303b6349ca8b14e3f284af3..91447636331957f3d9b5ca5b508f07c526b0074d:/bsd/hfs/hfs_endian.c?ds=sidebyside diff --git a/bsd/hfs/hfs_endian.c b/bsd/hfs/hfs_endian.c index cd5843aaf..0341f15db 100644 --- a/bsd/hfs/hfs_endian.c +++ b/bsd/hfs/hfs_endian.c @@ -355,6 +355,55 @@ hfs_swap_HFSPlusBTInternalNode ( if (unswap) srcPtr[0] = SWAP_BE16 (srcPtr[0]); } + } else if (fileID == kHFSAttributesFileID) { + HFSPlusAttrKey *srcKey; + HFSPlusAttrRecord *srcRec; + + for (i = 0; i < srcDesc->numRecords; i++) { + srcKey = (HFSPlusAttrKey *)((char *)src->buffer + srcOffs[i]); + + if (!unswap) srcKey->keyLength = SWAP_BE16(srcKey->keyLength); + srcRec = (HFSPlusAttrRecord *)((char *)srcKey + srcKey->keyLength + 2); + if (unswap) srcKey->keyLength = SWAP_BE16(srcKey->keyLength); + + srcKey->fileID = SWAP_BE32(srcKey->fileID); + srcKey->startBlock = SWAP_BE32(srcKey->startBlock); + + if (!unswap) srcKey->attrNameLen = SWAP_BE16(srcKey->attrNameLen); + for (j = 0; j < srcKey->attrNameLen; j++) + srcKey->attrName[j] = SWAP_BE16(srcKey->attrName[j]); + if (unswap) srcKey->attrNameLen = SWAP_BE16(srcKey->attrNameLen); + + /* If this is an index node, just swap the child node number */ + if (srcDesc->kind == kBTIndexNode) { + *((UInt32 *)srcRec) = SWAP_BE32 (*((UInt32 *)srcRec)); + continue; + } + + /* Swap the data record */ + if (!unswap) srcRec->recordType = SWAP_BE32(srcRec->recordType); + switch (srcRec->recordType) { + case kHFSPlusAttrInlineData: + /* We're not swapping the reserved fields */ + srcRec->attrData.attrSize = SWAP_BE32(srcRec->attrData.attrSize); + /* Not swapping the attrData */ + break; + case kHFSPlusAttrForkData: + /* We're not swapping the reserved field */ + hfs_swap_HFSPlusForkData(&srcRec->forkData.theFork); + break; + case kHFSPlusAttrExtents: + /* We're not swapping the reserved field */ + for (j = 0; j < kHFSPlusExtentDensity; j++) { + srcRec->overflowExtents.extents[j].startBlock = + SWAP_BE32(srcRec->overflowExtents.extents[j].startBlock); + srcRec->overflowExtents.extents[j].blockCount = + SWAP_BE32(srcRec->overflowExtents.extents[j].blockCount); + } + break; + } + if (unswap) srcRec->recordType = SWAP_BE32(srcRec->recordType); + } } else if (fileID > kHFSFirstUserCatalogNodeID) { HotFileKey *srcKey; UInt32 *srcRec;