Index: trunk/i386/libsaio/hfs.c =================================================================== --- trunk/i386/libsaio/hfs.c (revision 2478) +++ trunk/i386/libsaio/hfs.c (revision 2479) @@ -45,8 +45,8 @@ static long long gAllocationOffset; static long gIsHFSPlus; static long gCaseSensitive; -static long gBlockSize; -static long gCacheBlockSize; +static u_int32_t gBlockSize; +static u_int32_t gCacheBlockSize; static char *gBTreeHeaderBuffer; static BTHeaderRec *gBTHeaders[2]; static char *gHFSMdbVib; @@ -59,45 +59,45 @@ #else /* !__i386__ */ -static CICell gCurrentIH; -static long long gAllocationOffset; -static long gIsHFSPlus; -static long gBlockSize; -static long gCaseSensitive; -static long gCacheBlockSize; -static char gBTreeHeaderBuffer[512]; -static BTHeaderRec *gBTHeaders[2]; -static char gHFSMdbVib[kBlockSize]; -static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; -static char gHFSPlusHeader[kBlockSize]; -static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; -static char gLinkTemp[64]; -static long long gVolID; +static CICell gCurrentIH; +static long long gAllocationOffset; +static long gIsHFSPlus; +static long gCaseSensitive; +static u_int32_t gBlockSize; +static u_int32_t gCacheBlockSize; +static char gBTreeHeaderBuffer[512]; +static BTHeaderRec *gBTHeaders[2]; +static char gHFSMdbVib[kBlockSize]; +static HFSMasterDirectoryBlock *gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib; +static char gHFSPlusHeader[kBlockSize]; +static HFSPlusVolumeHeader *gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader; +static char gLinkTemp[64]; +static long long gVolID; #endif /* !__i386__ */ -static long ReadFile(void *file, uint64_t *length, void *base, uint64_t offset); -static long GetCatalogEntryInfo(void *entry, long *flags, long *time, +static long ReadFile(void *file, u_int64_t *length, void *base, u_int64_t offset); +static long GetCatalogEntryInfo(void *entry, long *flags, u_int32_t *time, FinderInfo *finderInfo, long *infoValid); static long ResolvePathToCatalogEntry(char *filePath, long *flags, - void *entry, long dirID, long long *dirIndex); + void *entry, u_int32_t dirID, long long *dirIndex); static long GetCatalogEntry(long long *dirIndex, char **name, - long *flags, long *time, + long *flags, u_int32_t *time, FinderInfo *finderInfo, long *infoValid); -static long ReadCatalogEntry(char *fileName, long dirID, void *entry, +static long ReadCatalogEntry(char *fileName, u_int32_t dirID, void *entry, long long *dirIndex); -static long ReadExtentsEntry(long fileID, long startBlock, void *entry); +static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void *entry); static long ReadBTreeEntry(long btree, void *key, char *entry, long long *dirIndex); -static void GetBTreeRecord(long index, char *nodeBuffer, long nodeSize, +static void GetBTreeRecord(u_int16_t index, char *nodeBuffer, u_int16_t nodeSize, char **key, char **data); -static long ReadExtent(char *extent, uint64_t extentSize, long extentFile, - uint64_t offset, uint64_t size, void *buffer, long cache); +static long ReadExtent(char *extent, u_int64_t extentSize, u_int32_t extentFile, + u_int64_t offset, u_int64_t size, void *buffer, long cache); -static long GetExtentStart(void *extents, long index); -static long GetExtentSize(void *extents, long index); +static u_int32_t GetExtentStart(void *extents, u_int32_t index); +static u_int32_t GetExtentSize(void *extents, u_int32_t index); static long CompareHFSCatalogKeys(void *key, void *testKey); static long CompareHFSPlusCatalogKeys(void *key, void *testKey); @@ -108,7 +108,6 @@ extern long BinaryUnicodeCompare(u_int16_t *uniStr1, u_int32_t len1, u_int16_t *uniStr2, u_int32_t len2); - //============================================================================== static void SwapFinderInfo(FndrFileInfo *dst, FndrFileInfo *src) @@ -153,8 +152,10 @@ long HFSInitPartition(CICell ih) { - long extentSize, extentFile, nodeSize; + u_int64_t extentSize; void *extent; + u_int32_t extentFile; + u_int16_t nodeSize; if (ih == gCurrentIH) { @@ -289,11 +290,12 @@ return HFSReadFile(ih, filePath, (void *)gFSLoadAddress, 0, 0); } -long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length) +long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length) { char entry[512]; char devStr[12]; - long dirID, result, flags; + u_int32_t dirID; + long result, flags; if (HFSInitPartition(ih) == -1) { @@ -355,12 +357,11 @@ return length; } -long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, - long * flags, long * time, - FinderInfo * finderInfo, long * infoValid) +long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - char entry[512]; - long dirID, dirFlags; + char entry[512]; + u_int32_t dirID; + long dirFlags; if (HFSInitPartition(ih) == -1) { @@ -433,21 +434,20 @@ void HFSGetDescription(CICell ih, char *str, long strMaxLen) { + long long dirIndex = 0; + char *name; + long flags; + u_int32_t firstLeafNode; + u_int32_t time; + u_int16_t nodeSize; - UInt16 nodeSize; - UInt32 firstLeafNode; - long long dirIndex; - char *name; - long flags, time; - if (HFSInitPartition(ih) == -1) { return; } - /* Fill some crucial data structures by side effect. */ - dirIndex = 0; - HFSGetDirEntry(ih, "/", &dirIndex, &name, &flags, &time, 0, 0); + /* Fill some crucial data structures by side effect. */ + HFSGetDirEntry(ih, "/", &dirIndex, &name, &flags, &time, 0, 0); /* Now we can loook up the volume name node. */ nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize); @@ -463,13 +463,14 @@ //============================================================================== -long HFSGetFileBlock(CICell ih, char *filePath, unsigned long long *firstBlock) +long HFSGetFileBlock(CICell ih, char *filePath, u_int64_t *firstBlock) { - char entry[512]; - long dirID, result, flags; - void *extents; - HFSCatalogFile *hfsFile = (void *)entry; - HFSPlusCatalogFile *hfsPlusFile = (void *)entry; + char entry[512]; + long result, flags; + u_int32_t dirID; + void *extents; + HFSCatalogFile *hfsFile = (void *)entry; + HFSPlusCatalogFile *hfsPlusFile = (void *)entry; if (HFSInitPartition(ih) == -1) { @@ -515,12 +516,12 @@ } #if DEBUG - printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0)); - printf("block size 0x%x\n", (unsigned long)gBlockSize); - printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset); + printf("extent start 0x%x\n", GetExtentStart(extents, 0)); + printf("block size 0x%x\n", gBlockSize); + printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset); #endif - *firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL; - return 0; + *firstBlock = ((u_int64_t) GetExtentStart(extents, 0) * (u_int64_t) gBlockSize + gAllocationOffset) / 512ULL; + return 0; } @@ -544,13 +545,13 @@ //============================================================================== // Private Functions -static long ReadFile(void * file, uint64_t * length, void * base, uint64_t offset) +static long ReadFile(void * file, u_int64_t * length, void * base, u_int64_t offset) { - void *extents; - long fileID; - uint64_t fileLength; - HFSCatalogFile *hfsFile = file; - HFSPlusCatalogFile *hfsPlusFile = file; + u_int64_t fileLength; + void *extents; + HFSCatalogFile *hfsFile = file; + HFSPlusCatalogFile *hfsPlusFile = file; + u_int32_t fileID; if (gIsHFSPlus) { @@ -590,11 +591,12 @@ return 0; } -static long GetCatalogEntryInfo(void * entry, long * flags, long * time, - FinderInfo * finderInfo, long * infoValid) +//============================================================================== + +static long GetCatalogEntryInfo(void * entry, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - long tmpTime = 0; - long valid = 0; + u_int32_t tmpTime = 0; + long valid = 0; // Get information about the file. @@ -661,13 +663,15 @@ return 0; } -static long ResolvePathToCatalogEntry(char * filePath, long * flags, - void * entry, long dirID, long long * dirIndex) +//============================================================================== + +static long ResolvePathToCatalogEntry(char * filePath, long * flags, void * entry, u_int32_t dirID, long long * dirIndex) { - char *restPath; - long result, cnt, subFolderID = 0; - long long tmpDirIndex; - HFSPlusCatalogFile *hfsPlusFile; + char *restPath; + long result, cnt; + u_int32_t subFolderID = 0; + long long tmpDirIndex; + HFSPlusCatalogFile *hfsPlusFile; // Copy the file name to gTempStr cnt = 0; @@ -729,14 +733,16 @@ return result; } -static long GetCatalogEntry(long long * dirIndex, char ** name, - long * flags, long * time, - FinderInfo * finderInfo, long * infoValid) +//============================================================================== + +static long GetCatalogEntry(long long * dirIndex, char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { - long extentSize, nodeSize, curNode, index; - void *extent; - char *nodeBuf, *testKey, *entry; - BTNodeDescriptor *node; + u_int64_t extentSize; + void *extent; + char *nodeBuf, *testKey, *entry; + BTNodeDescriptor *node; + u_int32_t curNode; + u_int16_t nodeSize, index; if (gIsHFSPlus) { @@ -753,8 +759,8 @@ nodeBuf = (char *)malloc(nodeSize); node = (BTNodeDescriptor *)nodeBuf; - index = (long) (*dirIndex % nodeSize); - curNode = (long) (*dirIndex / nodeSize); + index = (u_int16_t) (*dirIndex % nodeSize); + curNode = (u_int32_t) (*dirIndex / nodeSize); // Read the BTree node and get the record for index. ReadExtent(extent, extentSize, kHFSCatalogFileID, (long long) curNode * nodeSize, nodeSize, nodeBuf, 1); @@ -793,34 +799,46 @@ return 0; } -static long ReadCatalogEntry(char * fileName, long dirID, - void * entry, long long * dirIndex) +//============================================================================== + +static long ReadCatalogEntry(char * fileName, u_int32_t dirID, void * entry, long long * dirIndex) { - long length; - char key[sizeof(HFSPlusCatalogKey)]; - HFSCatalogKey *hfsKey = (HFSCatalogKey *)key; - HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key; - - // Make the catalog key. - if ( gIsHFSPlus ) - { - hfsPlusKey->parentID = SWAP_BE32(dirID); - length = strlen(fileName); - if (length > 255) length = 255; - utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, - &(hfsPlusKey->nodeName.length), 512, OSBigEndian); - } else { - hfsKey->parentID = SWAP_BE32(dirID); - length = strlen(fileName); - if (length > 31) length = 31; - hfsKey->nodeName[0] = length; - strncpy((char *)(hfsKey->nodeName + 1), fileName, length); - } + long length = strlen(fileName); + char key[sizeof(HFSPlusCatalogKey)]; + HFSCatalogKey *hfsKey = (HFSCatalogKey *)key; + HFSPlusCatalogKey *hfsPlusKey = (HFSPlusCatalogKey *)key; + // Make the catalog key. + if ( gIsHFSPlus ) + { + if (length > kHFSPlusMaxFileNameChars) + { + length = kHFSPlusMaxFileNameChars; + } + + hfsPlusKey->parentID = SWAP_BE32(dirID); + + utf_decodestr((u_int8_t *)fileName, hfsPlusKey->nodeName.unicode, &(hfsPlusKey->nodeName.length), 512, OSBigEndian); + } + else + { + if (length > kHFSMaxFileNameChars) + { + length = kHFSMaxFileNameChars; + } + + hfsKey->parentID = SWAP_BE32(dirID); + + hfsKey->nodeName[0] = length; + strncpy((char *)(hfsKey->nodeName + 1), fileName, length); + } + return ReadBTreeEntry(kBTreeCatalog, &key, entry, dirIndex); } -static long ReadExtentsEntry(long fileID, long startBlock, void * entry) +//============================================================================== + +static long ReadExtentsEntry(u_int32_t fileID, long startBlock, void * entry) { char key[sizeof(HFSPlusExtentKey)]; HFSExtentKey *hfsKey = (HFSExtentKey *)key; @@ -847,14 +865,15 @@ static long ReadBTreeEntry(long btree, void * key, char * entry, long long * dirIndex) { - long extentSize; - void *extent; - short extentFile; - char *nodeBuf; - BTNodeDescriptor *node; - long nodeSize, result = 0, entrySize = 0; - long curNode, index = 0, lowerBound, upperBound; - char *testKey, *recordData; + u_int64_t extentSize; + void *extent; + u_int16_t extentFile; + char *nodeBuf; + BTNodeDescriptor *node; + long result = 0, entrySize = 0; + u_int32_t curNode; + char *testKey, *recordData; + u_int16_t nodeSize, index = 0, lowerBound, upperBound; // Figure out which tree is being looked at. if (btree == kBTreeCatalog) @@ -1032,34 +1051,38 @@ return 0; } -static void GetBTreeRecord(long index, char * nodeBuffer, long nodeSize, - char ** key, char ** data) +//============================================================================== + +static void GetBTreeRecord(u_int16_t index, char * nodeBuffer, u_int16_t nodeSize, char ** key, char ** data) { - long keySize; - long recordOffset; - - recordOffset = SWAP_BE16(*((short *)(nodeBuffer + (nodeSize - 2 * index - 2)))); - *key = nodeBuffer + recordOffset; - if (gIsHFSPlus) { - keySize = SWAP_BE16(*(short *)*key); - *data = *key + 2 + keySize; - } else { - keySize = **key; - *data = *key + 2 + keySize - (keySize & 1); - } + u_int16_t recordOffset, keySize; + + recordOffset = SWAP_BE16(*((u_int16_t *)(nodeBuffer + (nodeSize - 2 * index - 2)))); + *key = nodeBuffer + recordOffset; + + if (gIsHFSPlus) + { + keySize = SWAP_BE16(*(u_int16_t *)*key); + *data = *key + 2 + keySize; + } + else + { + keySize = **key; + *data = *key + 2 + keySize - (keySize & 1); + } } -static long ReadExtent(char * extent, uint64_t extentSize, - long extentFile, uint64_t offset, uint64_t size, - void * buffer, long cache) +//============================================================================== + +static long ReadExtent(char * extent, u_int64_t extentSize, u_int32_t extentFile, u_int64_t offset, u_int64_t size, void * buffer, long cache) { - uint64_t lastOffset; - long long blockNumber, countedBlocks = 0; - long long nextExtent = 0, sizeRead = 0, readSize; - long long nextExtentBlock, currentExtentBlock = 0; - long long readOffset; - long long extentDensity, sizeofExtent, currentExtentSize; - char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; + u_int64_t lastOffset; + u_int64_t blockNumber, countedBlocks = 0; + u_int64_t nextExtent = 0, sizeRead = 0, readSize; + u_int64_t nextExtentBlock, currentExtentBlock = 0; + u_int64_t readOffset; + u_int64_t extentDensity, sizeofExtent, currentExtentSize; + char *currentExtent, *extentBuffer = 0, *bufferPos = buffer; if (offset >= extentSize) { @@ -1154,12 +1177,15 @@ return sizeRead; } -static long GetExtentStart(void * extents, long index) +//============================================================================== + +static u_int32_t GetExtentStart(void * extents, u_int32_t index) { - long start; - HFSExtentDescriptor *hfsExtents = extents; - HFSPlusExtentDescriptor *hfsPlusExtents = extents; + u_int32_t start; + HFSExtentDescriptor *hfsExtents = extents; + HFSPlusExtentDescriptor *hfsPlusExtents = extents; + if (gIsHFSPlus) { start = SWAP_BE32(hfsPlusExtents[index].startBlock); @@ -1172,15 +1198,24 @@ return start; } -static long GetExtentSize(void * extents, long index) +//============================================================================== + +static u_int32_t GetExtentSize(void * extents, u_int32_t index) { - long size; - HFSExtentDescriptor *hfsExtents = extents; - HFSPlusExtentDescriptor *hfsPlusExtents = extents; - - if (gIsHFSPlus) size = SWAP_BE32(hfsPlusExtents[index].blockCount); - else size = SWAP_BE16(hfsExtents[index].blockCount); + u_int32_t size = 0; + HFSExtentDescriptor *hfsExtents = extents; + HFSPlusExtentDescriptor *hfsPlusExtents = extents; + + if (gIsHFSPlus) + { + size = SWAP_BE32(hfsPlusExtents[index].blockCount); + } + else + { + size = SWAP_BE16(hfsExtents[index].blockCount); + } + return size; } Index: trunk/i386/libsaio/hfs.h =================================================================== --- trunk/i386/libsaio/hfs.h (revision 2478) +++ trunk/i386/libsaio/hfs.h (revision 2479) @@ -20,14 +20,16 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include + extern long HFSInitPartition(CICell ih); extern long HFSLoadFile(CICell ih, char * filePath); -extern long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length); +extern long HFSReadFile(CICell ih, char * filePath, void *base, u_int64_t offset, u_int64_t length); extern long HFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern void HFSGetDescription(CICell ih, char *str, long strMaxLen); -extern long HFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); +extern long HFSGetFileBlock(CICell ih, char *str, u_int64_t *firstBlock); extern long HFSGetUUID(CICell ih, char *uuidStr); extern void HFSFree(CICell ih); extern bool HFSProbe (const void *buf); Index: trunk/i386/libsaio/ufs.h =================================================================== --- trunk/i386/libsaio/ufs.h (revision 2478) +++ trunk/i386/libsaio/ufs.h (revision 2479) @@ -24,7 +24,7 @@ extern long UFSLoadFile(CICell ih, char * filePath); extern long UFSReadFile( CICell ih, char * filePath, void * base, uint64_t offset, uint64_t length ); extern long UFSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern void UFSGetDescription(CICell ih, char *str, long strMaxLen); extern long UFSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); Index: trunk/i386/libsaio/sys.c =================================================================== --- trunk/i386/libsaio/sys.c (revision 2478) +++ trunk/i386/libsaio/sys.c (revision 2479) @@ -357,7 +357,7 @@ // Fetch the next directory entry for the given directory. long GetDirEntry(const char * dirSpec, long long * dirIndex, const char ** name, - long * flags, long * time) + long * flags, u_int32_t * time) { const char * dirPath; BVRef bvr; @@ -384,7 +384,7 @@ static char* gMakeDirSpec; long GetFileInfo(const char * dirSpec, const char * name, - long * flags, long * time) + long * flags, u_int32_t * time) { long long index = 0; const char * entryName; @@ -829,7 +829,7 @@ //========================================================================== int readdir(struct dirstuff * dirp, const char ** name, long * flags, - long * time) + u_int32_t * time) { return dirp->dir_bvr->fs_getdirentry(dirp->dir_bvr, /* dirPath */ dirp->dir_path, @@ -840,7 +840,7 @@ //========================================================================== int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, - long * time, FinderInfo *finderInfo, long *infoValid) + u_int32_t * time, FinderInfo *finderInfo, long *infoValid) { return dirp->dir_bvr->fs_getdirentry( dirp->dir_bvr, /* dirPath */ dirp->dir_path, Index: trunk/i386/libsaio/disk.c =================================================================== --- trunk/i386/libsaio/disk.c (revision 2478) +++ trunk/i386/libsaio/disk.c (revision 2479) @@ -1652,7 +1652,8 @@ char dirSpec[512], fileSpec[512]; char label[BVSTRLEN]; int ret; - long flags, time; + long flags; + u_int32_t time; int fh, fileSize, error; for (bvr = chain; bvr; bvr = bvr->next) Index: trunk/i386/libsaio/cache.c =================================================================== --- trunk/i386/libsaio/cache.c (revision 2478) +++ trunk/i386/libsaio/cache.c (revision 2479) @@ -43,7 +43,7 @@ #define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize) static CICell gCacheIH; -static long gCacheBlockSize; +static u_int32_t gCacheBlockSize; static long gCacheNumEntries; static long gCacheTime; @@ -66,7 +66,7 @@ gCacheIH = NULL; } -void CacheInit( CICell ih, long blockSize ) +void CacheInit( CICell ih, u_int32_t blockSize ) { #ifdef __i386__ if ((ih == gCacheIH) && (blockSize == gCacheBlockSize)) @@ -113,7 +113,7 @@ bzero(gCacheEntries, kCacheMaxEntries * sizeof(CacheEntry)); } -long CacheRead(CICell ih, char * buffer, long long offset, long length, long cache) +u_int32_t CacheRead(CICell ih, char * buffer, long long offset, u_int32_t length, long cache) { long cnt, oldestEntry = 0, oldestTime, loadCache = 0; CacheEntry *entry; Index: trunk/i386/libsaio/saio_types.h =================================================================== --- trunk/i386/libsaio/saio_types.h (revision 2478) +++ trunk/i386/libsaio/saio_types.h (revision 2479) @@ -153,7 +153,7 @@ typedef long (*FSReadFile)(CICell ih, char *filePath, void *base, uint64_t offset, uint64_t length); typedef long (*FSGetFileBlock)(CICell ih, char *filePath, unsigned long long *firstBlock); typedef long (*FSGetDirEntry)(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); typedef long (*FSGetUUID)(CICell ih, char *uuidStr); typedef void (*BVGetDescription)(CICell ih, char * str, long strMaxLen); Index: trunk/i386/libsaio/msdos.c =================================================================== --- trunk/i386/libsaio/msdos.c (revision 2478) +++ trunk/i386/libsaio/msdos.c (revision 2479) @@ -659,7 +659,7 @@ } long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid) { struct msdosdirstate *st; Index: trunk/i386/libsaio/msdos.h =================================================================== --- trunk/i386/libsaio/msdos.h (revision 2478) +++ trunk/i386/libsaio/msdos.h (revision 2479) @@ -25,7 +25,7 @@ extern long MSDOSLoadFile(CICell ih, char * filePath); extern long MSDOSReadFile(CICell ih, char * filePath, void *base, uint64_t offset, uint64_t length); extern long MSDOSGetDirEntry(CICell ih, char * dirPath, long long * dirIndex, - char ** name, long * flags, long * time, + char ** name, long * flags, u_int32_t * time, FinderInfo * finderInfo, long * infoValid); extern long MSDOSGetFileBlock(CICell ih, char *str, unsigned long long *firstBlock); extern long MSDOSGetUUID(CICell ih, char *uuidStr); Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 2478) +++ trunk/i386/libsaio/saio_internal.h (revision 2479) @@ -80,11 +80,10 @@ extern void finalizeBootStruct(void); /* cache.c */ -extern void CacheReset(); -extern void CacheInit(CICell ih, long blockSize); -extern long CacheRead(CICell ih, char *buffer, long long offset, long length, long cache); +extern void CacheReset(); +extern void CacheInit(CICell ih, u_int32_t blockSize); +extern u_int32_t CacheRead(CICell ih, char *buffer, long long offset, u_int32_t length, long cache); - /* console.c */ extern bool gVerboseMode; extern bool gErrors; @@ -96,7 +95,7 @@ extern int printf(const char *format, ...); extern int error(const char *format, ...); extern int verbose(const char *format, ...); -extern void stop(const char *format, ...); +extern void stop(const char *format, ...) __attribute__ ((noreturn)); //Azi: replace getc/getchar with ? console.c extern void pause(); @@ -176,9 +175,9 @@ extern long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length); extern long LoadThinFatFile(const char *fileSpec, void **binary); extern long GetDirEntry(const char *dirSpec, long long *dirIndex, const char **name, - long *flags, long *time); + long *flags, u_int32_t *time); extern long GetFileInfo(const char *dirSpec, const char *name, - long *flags, long *time); + long *flags, u_int32_t *time); extern long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock); extern long GetFSUUID(char *spec, char *uuidStr); extern long CreateUUIDString(uint8_t uubytes[], int nbytes, char *uuidStr); @@ -197,9 +196,9 @@ extern struct dirstuff * opendir(const char *path); extern struct dirstuff * vol_opendir(BVRef bvr, const char *path); extern int closedir(struct dirstuff *dirp); -extern int readdir(struct dirstuff *dirp, const char **name, long *flags, long *time); +extern int readdir(struct dirstuff *dirp, const char **name, long *flags, u_int32_t *time); extern int readdir_ext(struct dirstuff * dirp, const char ** name, long * flags, - long * time, FinderInfo *finderInfo, long *infoValid); + u_int32_t * time, FinderInfo *finderInfo, long *infoValid); extern void flushdev(void); extern void scanBootVolumes(int biosdev, int *count); extern void scanDisks(int biosdev, int *count); Index: trunk/i386/boot2/drivers.c =================================================================== --- trunk/i386/boot2/drivers.c (revision 2478) +++ trunk/i386/boot2/drivers.c (revision 2479) @@ -279,8 +279,9 @@ static long FileLoadMKext( const char * dirSpec, const char * extDirSpec ) { - long ret, flags, time, time2; - char altDirSpec[512]; + long ret, flags; + u_int32_t time, time2; + char altDirSpec[512]; snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec); ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time); @@ -310,10 +311,11 @@ long FileLoadDrivers( char * dirSpec, long plugin ) { - long ret, length, flags, time, bundleType; - long long index; - long result = -1; - const char * name; + long long index; + long ret, length, flags, bundleType; + long result = -1; + u_int32_t time; + const char * name; if ( !plugin ) { Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 2478) +++ trunk/i386/boot2/boot.c (revision 2479) @@ -245,8 +245,9 @@ { char kernelCacheFile[512]; char kernelCachePath[512]; - long flags, time, cachetime, kerneltime, exttime, ret=-1; + long flags, ret=-1; unsigned long adler32; + u_int32_t time, cachetime, kerneltime, exttime; if((gBootMode & kBootModeSafe) != 0) { @@ -279,8 +280,8 @@ (archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64"); int lnam = strlen(kernelCacheFile) + 9; //with adler32 - char *name; - long prev_time = 0; + char *name; + u_int32_t prev_time = 0; struct dirstuff* cacheDir = opendir(kDefaultCachePathSnow); @@ -528,7 +529,8 @@ bool useKernelCache = true; // by default try to use the prelinked kernel const char *val; int len, ret = -1; - long flags, sleeptime, time; + long flags; + u_int32_t sleeptime, time; void *binary = (void *)kLoadAddr; char bootFile[sizeof(bootInfo->bootFile)]; @@ -832,7 +834,8 @@ bool checkOSVersion(const char * version) { - if ( (sizeof(version) > 4) && (version[3] == '1') ) { + if ( (sizeof(version) > 4) && ('.' != version[4]) && ('\0' != version[4]) ) + { return ((gMacOSVersion[0] == version[0]) && (gMacOSVersion[1] == version[1]) && (gMacOSVersion[2] == version[2]) && (gMacOSVersion[3] == version[3]) && (gMacOSVersion[4] == version[4])); Index: trunk/i386/boot2/modules.c =================================================================== --- trunk/i386/boot2/modules.c (revision 2478) +++ trunk/i386/boot2/modules.c (revision 2479) @@ -103,7 +103,7 @@ { char* name; long flags; - long time; + u_int32_t time; struct dirstuff* moduleDir = opendir("/Extra/modules/"); if(!moduleDir) { Index: trunk/i386/modules/AcpiCodec/acpi_codec.c =================================================================== --- trunk/i386/modules/AcpiCodec/acpi_codec.c (revision 2478) +++ trunk/i386/modules/AcpiCodec/acpi_codec.c (revision 2479) @@ -4743,9 +4743,10 @@ } { - long ret, length, flags, time; - long long index = 0; - const char * name; + long long index = 0; + long ret, length, flags; + u_int32_t time; + const char * name; U8 i = 0; char dirspec[512]; Index: trunk/CHANGES =================================================================== --- trunk/CHANGES (revision 2478) +++ trunk/CHANGES (revision 2479) @@ -1,5 +1,8 @@ - ErmaC : Rename decompress_lzvn function to lzvn_decode follow Apple source name. - bitshoveler : Fix "sed: RE error: illegal byte sequence", which turns out to be from feeding sed a TIFF file (buildpkg.sh) +- bitshoveler : CacheInit(), CacheRead() prototypes: use u_int32_t instead of long where appropriate (saio_internal.h) +- bitshoveler : Improved defensiveness against malloc failure (disk.c) +- bitshoveler : Use u_int32_t instead of long where appropriate (cache.c) - bitshoveler : Make some constant arrays static; other minor fixes (acpi_patcher.c) - bitshoveler : Make 'buffer' arg to aml_add_buffer 'const char *', was just 'char *' (aml_generator) - bitshoveler : Various fixes to problems exposed by Clang static analyzer (picopng.c)