Chameleon

Chameleon Commit Details

Date:2014-11-14 20:53:39 (5 years 11 months ago)
Author:ErmaC
Commit:2479
Parents: 2478
Message:CacheInit(), CacheRead() prototypes: use u_int32_t instead of long where appropriate (saio_internal.h), improved defensiveness against malloc failure (disk.c), use u_int32_t instead of long where appropriate (cache.c)
Changes:
M/trunk/i386/boot2/drivers.c
M/trunk/i386/libsaio/ufs.h
M/trunk/i386/libsaio/cache.c
M/trunk/i386/libsaio/saio_types.h
M/trunk/i386/libsaio/hfs.h
M/trunk/i386/libsaio/msdos.c
M/trunk/i386/boot2/boot.c
M/trunk/i386/modules/AcpiCodec/acpi_codec.c
M/trunk/i386/libsaio/disk.c
M/trunk/i386/libsaio/msdos.h
M/trunk/i386/boot2/modules.c
M/trunk/CHANGES
M/trunk/i386/libsaio/saio_internal.h
M/trunk/i386/libsaio/sys.c
M/trunk/i386/libsaio/hfs.c

File differences

trunk/i386/libsaio/hfs.c
4545
4646
4747
48
49
48
49
5050
5151
5252
......
5959
6060
6161
62
63
64
65
66
67
68
69
70
71
72
73
74
75
62
63
64
65
66
67
68
69
70
71
72
73
74
75
7676
7777
7878
79
80
79
80
8181
8282
83
83
8484
8585
86
86
8787
88
88
8989
90
90
9191
9292
93
93
9494
9595
96
97
96
97
9898
99
100
99
100
101101
102102
103103
......
108108
109109
110110
111
112111
113112
114113
......
153152
154153
155154
156
155
157156
157
158
158159
159160
160161
......
289290
290291
291292
292
293
293294
294295
295296
296
297
298
297299
298300
299301
......
355357
356358
357359
358
359
360
360
361361
362
363
362
363
364
364365
365366
366367
......
433434
434435
435436
437
438
439
440
441
442
436443
437
438
439
440
441
442
443444
444445
445446
446447
447448
448
449
450
449
450
451451
452452
453453
......
463463
464464
465465
466
466
467467
468
469
470
471
472
468
469
470
471
472
473
473474
474475
475476
......
515516
516517
517518
518
519
520
519
520
521
521522
522
523
523
524
524525
525526
526527
......
544545
545546
546547
547
548
548549
549
550
551
552
553
550
551
552
553
554
554555
555556
556557
......
590591
591592
592593
593
594
594
595
596
595597
596
597
598
599
598600
599601
600602
......
661663
662664
663665
664
665
666
667
668
666669
667
668
669
670
670
671
672
673
674
671675
672676
673677
......
729733
730734
731735
732
733
734
736
737
738
735739
736
737
738
739
740
741
742
743
744
745
740746
741747
742748
......
753759
754760
755761
756
757
762
763
758764
759765
760766
......
793799
794800
795801
796
797
802
803
804
798805
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
806
807
808
809
819810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
820836
821837
822838
823
839
840
841
824842
825843
826844
......
847865
848866
849867
850
851
852
853
854
855
856
857
868
869
870
871
872
873
874
875
876
858877
859878
860879
......
10321051
10331052
10341053
1035
1036
1054
1055
1056
10371057
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
10501073
10511074
1052
1053
1054
1075
1076
1077
10551078
1056
1057
1058
1059
1060
1061
1062
1079
1080
1081
1082
1083
1084
1085
10631086
10641087
10651088
......
11541177
11551178
11561179
1157
1180
1181
1182
11581183
1159
1160
1161
1184
11621185
1186
1187
1188
11631189
11641190
11651191
......
11721198
11731199
11741200
1175
1201
1202
1203
11761204
1177
1178
1179
1180
1181
1182
1205
11831206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
11841219
11851220
11861221
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;
#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 CICellgCurrentIH;
static long longgAllocationOffset;
static longgIsHFSPlus;
static longgCaseSensitive;
static u_int32_tgBlockSize;
static u_int32_tgCacheBlockSize;
static chargBTreeHeaderBuffer[512];
static BTHeaderRec*gBTHeaders[2];
static chargHFSMdbVib[kBlockSize];
static HFSMasterDirectoryBlock*gHFSMDB =(HFSMasterDirectoryBlock*)gHFSMdbVib;
static chargHFSPlusHeader[kBlockSize];
static HFSPlusVolumeHeader*gHFSPlus =(HFSPlusVolumeHeader*)gHFSPlusHeader;
static chargLinkTemp[64];
static long longgVolID;
#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);
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)
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)
{
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)
{
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)
{
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);
//==============================================================================
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)
{
}
#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;
}
//==============================================================================
// 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)
{
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.
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;
longresult, cnt;
u_int32_tsubFolderID = 0;
long longtmpDirIndex;
HFSPlusCatalogFile*hfsPlusFile;
// Copy the file name to gTempStr
cnt = 0;
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)
{
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);
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;
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)
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)
{
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);
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;
}
trunk/i386/libsaio/hfs.h
2020
2121
2222
23
24
2325
2426
25
27
2628
27
29
2830
2931
30
32
3133
3234
3335
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/types.h>
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);
trunk/i386/libsaio/ufs.h
2424
2525
2626
27
27
2828
2929
3030
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);
trunk/i386/libsaio/sys.c
357357
358358
359359
360
360
361361
362362
363363
......
384384
385385
386386
387
387
388388
389389
390390
......
829829
830830
831831
832
832
833833
834834
835835
......
840840
841841
842842
843
843
844844
845845
846846
// 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;
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;
//==========================================================================
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,
//==========================================================================
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,
trunk/i386/libsaio/disk.c
16521652
16531653
16541654
1655
1655
1656
16561657
16571658
16581659
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)
trunk/i386/libsaio/cache.c
4343
4444
4545
46
46
4747
4848
4949
......
6666
6767
6868
69
69
7070
7171
7272
......
113113
114114
115115
116
116
117117
118118
119119
#define kCacheMaxEntries (kCacheSize / kCacheMinBlockSize)
static CICell gCacheIH;
static long gCacheBlockSize;
static u_int32_t gCacheBlockSize;
static long gCacheNumEntries;
static long gCacheTime;
gCacheIH = NULL;
}
void CacheInit( CICell ih, long blockSize )
void CacheInit( CICell ih, u_int32_t blockSize )
{
#ifdef __i386__
if ((ih == gCacheIH) && (blockSize == gCacheBlockSize))
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;
trunk/i386/libsaio/saio_types.h
153153
154154
155155
156
156
157157
158158
159159
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);
trunk/i386/libsaio/msdos.c
659659
660660
661661
662
662
663663
664664
665665
}
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;
trunk/i386/libsaio/msdos.h
2525
2626
2727
28
28
2929
3030
3131
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);
trunk/i386/libsaio/saio_internal.h
8080
8181
8282
83
84
85
83
84
85
8686
87
8887
8988
9089
......
9695
9796
9897
99
98
10099
101100
102101
......
176175
177176
178177
179
178
180179
181
180
182181
183182
184183
......
197196
198197
199198
200
199
201200
202
201
203202
204203
205204
extern void finalizeBootStruct(void);
/* cache.c */
extern voidCacheReset();
extern voidCacheInit(CICell ih, long blockSize);
extern longCacheRead(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;
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();
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);
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);
trunk/i386/boot2/drivers.c
279279
280280
281281
282
283
282
283
284
284285
285286
286287
......
310311
311312
312313
313
314
315
316
314
315
316
317
318
317319
318320
319321
static long FileLoadMKext( const char * dirSpec, const char * extDirSpec )
{
longret, flags, time, time2;
charaltDirSpec[512];
longret, flags;
u_int32_ttime, time2;
charaltDirSpec[512];
snprintf(altDirSpec, sizeof(altDirSpec), "%s%s", dirSpec, extDirSpec);
ret = GetFileInfo(altDirSpec, "Extensions.mkext", &flags, &time);
long FileLoadDrivers( char * dirSpec, long plugin )
{
long ret, length, flags, time, bundleType;
long long index;
long result = -1;
const char * name;
long longindex;
longret, length, flags, bundleType;
longresult = -1;
u_int32_ttime;
const char* name;
if ( !plugin )
{
trunk/i386/boot2/boot.c
245245
246246
247247
248
248
249249
250
250251
251252
252253
......
279280
280281
281282
282
283
283
284
284285
285286
286287
......
528529
529530
530531
531
532
533
532534
533535
534536
......
832834
833835
834836
835
837
838
836839
837840
838841
{
charkernelCacheFile[512];
charkernelCachePath[512];
longflags, time, cachetime, kerneltime, exttime, ret=-1;
longflags, ret=-1;
unsigned long adler32;
u_int32_t time, cachetime, kerneltime, exttime;
if((gBootMode & kBootModeSafe) != 0)
{
(archCpuType == CPU_TYPE_I386) ? "i386" : "x86_64");
intlnam = strlen(kernelCacheFile) + 9; //with adler32
char*name;
longprev_time = 0;
char *name;
u_int32_t prev_time = 0;
structdirstuff* cacheDir = opendir(kDefaultCachePathSnow);
booluseKernelCache = true; // by default try to use the prelinked kernel
const char*val;
intlen, ret = -1;
longflags, sleeptime, time;
longflags;
u_int32_tsleeptime, time;
void*binary = (void *)kLoadAddr;
charbootFile[sizeof(bootInfo->bootFile)];
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]));
trunk/i386/boot2/modules.c
103103
104104
105105
106
106
107107
108108
109109
{
char* name;
long flags;
long time;
u_int32_t time;
struct dirstuff* moduleDir = opendir("/Extra/modules/");
if(!moduleDir)
{
trunk/i386/modules/AcpiCodec/acpi_codec.c
47434743
47444744
47454745
4746
4747
4748
4746
4747
4748
4749
47494750
47504751
47514752
}
{
long ret, length, flags, time;
long long index = 0;
const char * name;
long longindex = 0;
longret, length, flags;
u_int32_ttime;
const char* name;
U8 i = 0;
char dirspec[512];
trunk/CHANGES
11
22
3
4
5
36
47
58
- 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)

Archive Download the corresponding diff file

Revision: 2479