Index: trunk/i386/libsaio/fake_efi.c =================================================================== --- trunk/i386/libsaio/fake_efi.c (revision 1648) +++ trunk/i386/libsaio/fake_efi.c (revision 1649) @@ -620,6 +620,21 @@ } /* + * Populate the chosen node + */ +void setupChosenNode() +{ + Node *chosenNode; + chosenNode = DT__FindNode("/chosen", false); + if (chosenNode == 0) + stop("Couldn't get chosen node"); + + int bootUUIDLength = strlen(gBootUUIDString); + if (bootUUIDLength) + DT__AddProperty(chosenNode, "boot-uuid", bootUUIDLength + 1, gBootUUIDString); +} + +/* * Load the smbios.plist override config file if any */ static void setupSmbiosConfigFile(const char *filename) @@ -683,6 +698,9 @@ gST64->Hdr.CRC32 = 0; gST64->Hdr.CRC32 = crc32(0L, gST64, gST64->Hdr.HeaderSize); } + + // Setup the chosen node + setupChosenNode(); } void saveOriginalSMBIOS(void) Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 1648) +++ trunk/i386/boot2/boot.c (revision 1649) @@ -72,7 +72,7 @@ static char gCacheNameAdler[64 + 256]; char *gPlatformName = gCacheNameAdler; -char gRootDevice[512]; +char gRootDevice[ROOT_DEVICE_SIZE]; char gMKextName[512]; char gMacOSVersion[8]; int bvCount = 0, gDeviceCount = 0; Index: trunk/i386/boot2/boot.h =================================================================== --- trunk/i386/boot2/boot.h (revision 1648) +++ trunk/i386/boot2/boot.h (revision 1649) @@ -147,6 +147,7 @@ * A global set by boot() to record the device that the booter * was loaded from. */ +#define ROOT_DEVICE_SIZE 512 extern int gBIOSDev; extern long gBootMode; extern bool sysConfigValid; @@ -224,9 +225,11 @@ /* * options.c */ -extern int getBootOptions(bool firstRun); -extern int processBootOptions(); -extern int selectAlternateBootDevice(int bootdevice); +extern char gBootUUIDString[]; + +extern int getBootOptions(bool firstRun); +extern int processBootOptions(); +extern int selectAlternateBootDevice(int bootdevice); extern bool promptForRescanOption(void); void showHelp(); Index: trunk/i386/boot2/options.c =================================================================== --- trunk/i386/boot2/options.c (revision 1648) +++ trunk/i386/boot2/options.c (revision 1649) @@ -1063,6 +1063,7 @@ //========================================================================== +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; @@ -1105,7 +1106,8 @@ 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; @@ -1122,9 +1124,8 @@ 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; } @@ -1134,17 +1135,15 @@ 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); @@ -1224,35 +1223,34 @@ 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] = '*'; @@ -1260,7 +1258,7 @@ strlcpy(valueBuffer + 1, val, cnt); val = valueBuffer; } else { - if (uuidSet) { + if (strlen(gBootUUIDString)) { val = "*uuid"; cnt = 5; } else { @@ -1279,7 +1277,8 @@ /* * 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); }