Chameleon

Chameleon Commit Details

Date:2011-08-19 20:54:45 (8 years 2 months ago)
Author:JrCs
Commit:1439
Parents: 1438
Message:Use prelink kernel cache file when booting Lion from RAID volumes
Changes:
M/trunk/i386/boot2/boot.c

File differences

trunk/i386/boot2/boot.c
364364
365365
366366
367
367
368368
369369
370370
......
487487
488488
489489
490
491
490
491
492
493
494
495
496
497
498
499
492500
493501
494502
......
498506
499507
500508
501
509
502510
503511
504512
505
513
506514
507515
508516
......
537545
538546
539547
540
548
541549
542550
543551
......
545553
546554
547555
548
556
557
558
559
549560
550
551
552
561
562
563
564
553565
554566
555567
556
557
558
559
568
569
570
571
572
573
560574
561575
562576
563
577
564578
565
566
579
580
581
582
567583
568584
569585
570
571
572
573
574
575
576
577
578
579586
580587
581588
while (1)
{
booltryresume, tryresumedefault, forceresume;
boolusecache = false;//true;
booluseKernelCache = false; // by default don't use prelink kernel cache
const char*val;
intlen, trycache, ret = -1;
longflags, cachetime, kerneltime, exttime, sleeptime, time;
break;
}
getBoolForKey(kUseKernelCache, &usecache, &bootInfo->chameleonConfig);
if (usecache) {
// If boot from boot helper partitions and OS is Lion use prelink kernel.
// We need to find a solution to load extra mkext with a prelink kernel.
if (gBootVolume->flags & kBVFlagBooter && checkOSVersion("10.7")) {
verbose("Booting from Lion RAID volume so forcing to use KernelCache\n");
useKernelCache = true;
} else {
getBoolForKey(kUseKernelCache, &useKernelCache, &bootInfo->chameleonConfig);
}
if (useKernelCache) {
if (getValueForKey(kKernelCacheKey, &val, &len, &bootInfo->bootConfig)) {
if (val[0] == '\\')
{
strlcpy(gBootKernelCacheFile, val, len + 1);
}
else {
//Lion
// Lion prelink kernel cache file
if (checkOSVersion("10.7")) {
sprintf(gBootKernelCacheFile, "%skernelcache", kDefaultCachePathSnow);
}
// Snow Leopard
// Snow Leopard prelink kernel cache file
else if (checkOSVersion("10.6")) {
sprintf(gBootKernelCacheFile, "kernelcache_%s", (archCpuType == CPU_TYPE_I386)
? "i386" : "x86_64");
}
// Check for cache file.
trycache = (usecache &&
trycache = (useKernelCache &&
((gBootMode & kBootModeSafe) == 0) &&
!gOverrideKernel &&
(gBootFileType == kBlockDeviceType) &&
(gBootKernelCacheFile[0] != '\0'));
verbose("Loading Darwin %s\n", gMacOSVersion);
// Check if the kernel cache file exists and is more recent (mtime) than
// the kernel file or the S/L/E directory
if (trycache) do {
ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
if (ret != 0) kerneltime = 0;
else if ((flags & kFileTypeMask) != kFileTypeFlat) {
ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
// Check if the kernel cache file exist
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
trycache = 0;
break;
}
ret = GetFileInfo(NULL, gBootKernelCacheFile, &flags, &cachetime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat)
|| (cachetime < kerneltime)) {
ret = GetFileInfo(NULL, bootInfo->bootFile, &flags, &kerneltime);
if ((ret != 0) || ((flags & kFileTypeMask) != kFileTypeFlat))
kerneltime = -1;
// Check if the kernel file is more recent than the cache file
if (kerneltime > cachetime) {
trycache = 0;
break;
}
ret = GetFileInfo("/System/Library/", "Extensions", &flags, &exttime);
if ((ret == 0) && ((flags & kFileTypeMask) == kFileTypeDirectory)
&& (cachetime < exttime)) {
if ((ret != 0) && ((flags & kFileTypeMask) != kFileTypeDirectory))
exttime = -1;
// Check if the S/L/E directory time is more recent than the cache file
if (exttime > cachetime) {
trycache = 0;
break;
}
if (ret == 0 && kerneltime > exttime) {
exttime = kerneltime;
}
if (ret == 0 && cachetime != (exttime + 1)) {
trycache = 0;
break;
}
} while (0);
do {

Archive Download the corresponding diff file

Revision: 1439