␊ |
//==========================================================================␊ |
␊ |
char gBootUUIDString[32+4+1] = ""; // UUID of the boot volume e.g. 5EB1869F-C4FA-3502-BDEB-3B8ED5D87292␊ |
extern unsigned char chainbootdev;␊ |
extern unsigned char chainbootflag;␊ |
␊ |
|
const char *configTable,␊ |
char **argP, // Output value␊ |
int *cntRemainingP, // Output count␊ |
char *foundVal // found value␊ |
char *foundVal, // found value␊ |
int foundValSize // max found value size␊ |
)␊ |
{␊ |
const char *val;␊ |
|
copyArgument(argName, val, cnt, argP, cntRemainingP);␊ |
found = true;␊ |
}␊ |
if (found && foundVal) {␊ |
strlcpy(foundVal, val, cnt+1);␊ |
}␊ |
if (found && foundVal)␊ |
strlcpy(foundVal, val, foundValSize);␊ |
return found;␊ |
}␊ |
␊ |
|
int␊ |
processBootOptions()␊ |
{␊ |
const char * cp = gBootArgs;␊ |
const char * val = 0;␊ |
const char * kernel;␊ |
int cnt;␊ |
int␉␉ userCnt;␊ |
int cntRemaining;␊ |
char * argP;␊ |
char uuidStr[64];␊ |
bool uuidSet = false;␊ |
char * configKernelFlags;␊ |
char * valueBuffer;␊ |
const char *cp = gBootArgs;␊ |
const char *val = 0;␊ |
const char *kernel;␊ |
int cnt;␊ |
int userCnt;␊ |
int cntRemaining;␊ |
char *argP;␊ |
char *configKernelFlags;␊ |
char *valueBuffer;␊ |
␊ |
valueBuffer = malloc(VALUE_SIZE);␊ |
␊ |
|
configKernelFlags = malloc(cnt + 1);␊ |
strlcpy(configKernelFlags, val, cnt + 1);␊ |
␊ |
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {␊ |
// boot-uuid was set either on the command-line␊ |
// or in the config file.␊ |
uuidSet = true;␊ |
} else {␊ |
␊ |
// boot-uuid can be set either on the command-line or in the config file␊ |
␉if (!processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config,␊ |
&argP, &cntRemaining, gBootUUIDString, sizeof(gBootUUIDString))) {␊ |
//␊ |
// Try an alternate method for getting the root UUID on boot helper partitions.␊ |
//␊ |
if (gBootVolume->flags & kBVFlagBooter)␊ |
{␊ |
␉if((loadHelperConfig(&bootInfo->helperConfig) == 0)␊ |
␉ && getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig) )␊ |
␉␉{␊ |
␉␉␉// Load the configuration store in the boot helper partition␊ |
␉␉␉if (loadHelperConfig(&bootInfo->helperConfig) == 0)␊ |
␉{␊ |
␉getValueForKey(kHelperRootUUIDKey, &val, &cnt, &bootInfo->helperConfig);␊ |
copyArgument(kBootUUIDKey, val, cnt, &argP, &cntRemaining);␊ |
uuidSet = true;␊ |
␉}␊ |
␉␉␉␉val = getStringForKey(kHelperRootUUIDKey, &bootInfo->helperConfig);␊ |
␉␉␉␉if (val != NULL)␊ |
␉␉␉␉␉strlcpy(gBootUUIDString, val, sizeof(gBootUUIDString));␊ |
␉␉␉}␊ |
}␊ |
␊ |
if (!uuidSet && gBootVolume->fs_getuuid && gBootVolume->fs_getuuid (gBootVolume, uuidStr) == 0) {␊ |
verbose("Setting boot-uuid to: %s\n", uuidStr);␊ |
copyArgument(kBootUUIDKey, uuidStr, strlen(uuidStr), &argP, &cntRemaining);␊ |
uuidSet = true;␊ |
}␊ |
// Try to get the volume uuid string␊ |
␉␉if (!strlen(gBootUUIDString) && gBootVolume->fs_getuuid)␊ |
␉␉␉gBootVolume->fs_getuuid(gBootVolume, gBootUUIDString);␊ |
␊ |
}␊ |
␉␉// If we have the volume uuid add it to the commandline arguments␊ |
␉␉if (strlen(gBootUUIDString))␊ |
␉␉␉copyArgument(kBootUUIDKey, gBootUUIDString, strlen(gBootUUIDString), &argP, &cntRemaining);␊ |
␉}␊ |
␊ |
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gRootDevice)) {␊ |
if (!processBootArgument(kRootDeviceKey, cp, configKernelFlags, bootInfo->config,␊ |
&argP, &cntRemaining, gRootDevice, ROOT_DEVICE_SIZE)) {␊ |
cnt = 0;␊ |
if ( getValueForKey( kBootDeviceKey, &val, &cnt, &bootInfo->chameleonConfig)) {␊ |
valueBuffer[0] = '*';␊ |
|
strlcpy(valueBuffer + 1, val, cnt);␊ |
val = valueBuffer;␊ |
} else {␊ |
if (uuidSet) {␊ |
if (strlen(gBootUUIDString)) {␊ |
val = "*uuid";␊ |
cnt = 5;␊ |
} else {␊ |
|
/*␊ |
* Removed. We don't need this anymore.␊ |
*␊ |
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, gPlatformName)) {␊ |
if (!processBootArgument(kPlatformKey, cp, configKernelFlags, bootInfo->config,␊ |
␉␉␉␉␉␉␉ &argP, &cntRemaining, gPlatformName, sizeof(gCacheNameAdler))) {␊ |
getPlatformName(gPlatformName);␊ |
copyArgument(kPlatformKey, gPlatformName, strlen(gPlatformName), &argP, &cntRemaining);␊ |
}␊ |