Index: branches/azimutz/Chazileon/i386/libsaio/disk.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/disk.c (revision 447) +++ branches/azimutz/Chazileon/i386/libsaio/disk.c (revision 448) @@ -1604,7 +1604,7 @@ /* Looking for "Hide Partition" entries in 'hd(x,y)|uuid|"label" hd(m,n)|uuid|"label"' format * to be able to hide foreign partitions from the boot menu. */ - if ( (newBVR->flags & kBVFlagForeignBoot) ) + if ( (newBVR->flags & kBVFlagForeignBoot) ) //Azi: enable hiding native boot? { char *start, *next = val; long len = 0; @@ -1699,7 +1699,7 @@ bool matchVolumeToString( BVRef bvr, const char* match, long matchLen) { char testStr[128]; - + if ( !bvr || !match || !*match) return 0; @@ -1729,9 +1729,9 @@ return false; } -/* If Rename Partition has defined an alias, then extract it for description purpose +/* If Rename Partition has defined an alias, then extract it for description purpose. * The format for the rename string is the following: - * hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" etc; ... + * hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias";etc... */ bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen) @@ -1770,7 +1770,7 @@ if ( matchVolumeToString(bvr, volStart, volLen) ) { - strncpy(str, aliasStart, min(strMaxLen, aliasLen)); + strncat(str, aliasStart, min(strMaxLen, aliasLen)); free(aliasList); return true; @@ -1805,7 +1805,8 @@ /* See if a partition rename is preferred */ if(getVolumeLabelAlias(bvr, p, strMaxLen)) { - //verbose("Renamed: %s\n", p); Azi:remove?? + //verbose("Renamed: %s\n", p); Azi:remove?? + strncpy(bvr->label, p, strMaxLen); return; // we're done here no need to seek for real name } Index: branches/azimutz/Chazileon/i386/boot2/graphics.c =================================================================== --- branches/azimutz/Chazileon/i386/boot2/graphics.c (revision 447) +++ branches/azimutz/Chazileon/i386/boot2/graphics.c (revision 448) @@ -1234,7 +1234,8 @@ { currentIndicator = 0; } - printf("%c\b", indicator[currentIndicator++]); + putc(indicator[currentIndicator++]); + putc('\b'); } } @@ -1243,7 +1244,8 @@ { if ( getVideoMode() == VGA_TEXT_MODE ) { - printf(" \b"); + putc(' '); + putc('\b'); } } Index: branches/azimutz/Chazileon/i386/boot2/options.c =================================================================== --- branches/azimutz/Chazileon/i386/boot2/options.c (revision 447) +++ branches/azimutz/Chazileon/i386/boot2/options.c (revision 448) @@ -44,7 +44,8 @@ //extern int menucount; extern int gDeviceCount; -char gMacOSVersion[8]; +char gMacOSVersion[8]; //Azi: moved from boot.c +static bool getOSVersion(char *str); // || int selectIndex = 0; MenuItem * menuItems = NULL; @@ -117,7 +118,7 @@ position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) ); char dummy[80]; - getBootVolumeDescription( gBootVolume, dummy, 80, true ); + getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true ); drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true ); drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos ); @@ -776,28 +777,24 @@ // When booting from CD, default to hard drive boot when possible. if (isCDROM && firstRun) { const char *val; - char *prompt; - char *name; + char *prompt = NULL; + char *name = NULL; int cnt; int optionKey; if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) { - cnt += 1; - prompt = malloc(cnt); - strlcpy(prompt, val, cnt); + prompt = malloc(cnt + 1); + strncat(prompt, val, cnt); } else { name = malloc(80); - getBootVolumeDescription(gBootVolume, name, 80, false); + getBootVolumeDescription(gBootVolume, name, 79, false); prompt = malloc(256); sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name); free(name); - cnt = 0; } if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) { // The key specified is a special key. - } else if (getValueForKey( kCDROMOptionKey, &val, &cnt, &bootInfo->bootConfig ) && cnt >= 1) { - optionKey = val[0]; } else { // Default to F8. optionKey = 0x4200; @@ -812,7 +809,7 @@ key = optionKey; } - if (cnt) { + if (prompt != NULL) { free(prompt); } @@ -864,7 +861,7 @@ // Associate a menu item for each BVRef. for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) { if (bvr->visible) { - getBootVolumeDescription(bvr, menuItems[i].name, 80, true); + getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true); menuItems[i].param = (void *) bvr; if (bvr == menuBVR) { selectIndex = i; @@ -1267,8 +1264,6 @@ const char * cp = gBootArgs; const char * val = 0; const char * kernel; - const char *value; - int len; int cnt; int userCnt; int cntRemaining; @@ -1277,7 +1272,6 @@ bool uuidSet = false; char * configKernelFlags; char * valueBuffer; - config_file_t systemVersion; valueBuffer = malloc(VALUE_SIZE); @@ -1309,18 +1303,9 @@ else return -1; - // Needed here to enable search for override Boot.plist on OS specific folders. + // Moved here to enable search for override Boot.plist on OS specific folders. // Find out which Mac OS version we're booting. - if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion)) - { - if (getValueForKey(kProductVersion, &value, &len, &systemVersion)) - { - // getValueForKey uses const char for val - // so copy it and trim - strncpy(gMacOSVersion, value, MIN(len, 4)); - gMacOSVersion[MIN(len, 4)] = '\0'; - } - } + getOSVersion(gMacOSVersion); //Azi: implemented at loadOverrideConfig. // Load config table specified by the user, or use the default. @@ -1476,7 +1461,38 @@ return 0; } +static bool getOSVersion(char *str) //Azi: moved from boot.c +{ + bool valid = false; + config_file_t systemVersion; + const char *val; + int len; + if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion)) + { //Azi: so, is this path on selected or current volume?? + valid = true; + } + else if (!loadConfigFile("/System/Library/CoreServices/ServerVersion.plist", &systemVersion)) + { + valid = true; + } + + if (valid) + { + if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) + { + // getValueForKey uses const char for val + // so copy it and trim + *str = '\0'; + strncat(str, val, min(len, 4)); + } + else + valid = false; + } + + return valid; +} + //========================================================================== // Load the help file and display the file contents on the screen. Index: branches/azimutz/CleanCut/i386/libsaio/disk.c =================================================================== --- branches/azimutz/CleanCut/i386/libsaio/disk.c (revision 447) +++ branches/azimutz/CleanCut/i386/libsaio/disk.c (revision 448) @@ -1699,7 +1699,7 @@ bool matchVolumeToString( BVRef bvr, const char* match, long matchLen) { char testStr[128]; - + if ( !bvr || !match || !*match) return 0; @@ -1729,9 +1729,9 @@ return false; } -/* If Rename Partition has defined an alias, then extract it for description purpose +/* If Rename Partition has defined an alias, then extract it for description purpose. * The format for the rename string is the following: - * hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" etc; ... + * hd(x,y)|uuid|"label" "alias";hd(m,n)|uuid|"label" "alias";etc... */ bool getVolumeLabelAlias(BVRef bvr, char* str, long strMaxLen) @@ -1770,7 +1770,7 @@ if ( matchVolumeToString(bvr, volStart, volLen) ) { - strncpy(str, aliasStart, min(strMaxLen, aliasLen)); + strncat(str, aliasStart, min(strMaxLen, aliasLen)); free(aliasList); return true; Index: branches/azimutz/CleanCut/i386/boot2/graphics.c =================================================================== --- branches/azimutz/CleanCut/i386/boot2/graphics.c (revision 447) +++ branches/azimutz/CleanCut/i386/boot2/graphics.c (revision 448) @@ -1209,7 +1209,8 @@ { currentIndicator = 0; } - printf("%c\b", indicator[currentIndicator++]); + putc(indicator[currentIndicator++]); + putc('\b'); } } @@ -1218,7 +1219,8 @@ { if ( getVideoMode() == VGA_TEXT_MODE ) { - printf(" \b"); + putc(' '); + putc('\b'); } } Index: branches/azimutz/CleanCut/i386/boot2/options.c =================================================================== --- branches/azimutz/CleanCut/i386/boot2/options.c (revision 447) +++ branches/azimutz/CleanCut/i386/boot2/options.c (revision 448) @@ -40,7 +40,8 @@ //extern int menucount; extern int gDeviceCount; -char gMacOSVersion[8]; +char gMacOSVersion[8]; //Azi: moved from boot.c +static bool getOSVersion(char *str); // || int selectIndex = 0; MenuItem * menuItems = NULL; @@ -113,7 +114,7 @@ position_t p = pos( gui.screen.width / 2 + 1 , ( gui.devicelist.pos.y + 3 ) + ( ( gui.devicelist.height - gui.devicelist.iconspacing ) / 2 ) ); char dummy[80]; - getBootVolumeDescription( gBootVolume, dummy, 80, true ); + getBootVolumeDescription( gBootVolume, dummy, sizeof(dummy) - 1, true ); drawDeviceIcon( gBootVolume, gui.screen.pixmap, p, true ); drawStrCenteredAt( (char *) msg, &font_small, gui.screen.pixmap, gui.countdown.pos ); @@ -772,28 +773,24 @@ // When booting from CD, default to hard drive boot when possible. if (isCDROM && firstRun) { const char *val; - char *prompt; - char *name; + char *prompt = NULL; + char *name = NULL; int cnt; int optionKey; if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) { - cnt += 1; - prompt = malloc(cnt); - strlcpy(prompt, val, cnt); + prompt = malloc(cnt + 1); + strncat(prompt, val, cnt); } else { name = malloc(80); - getBootVolumeDescription(gBootVolume, name, 80, false); + getBootVolumeDescription(gBootVolume, name, 79, false); prompt = malloc(256); sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name); free(name); - cnt = 0; } if (getIntForKey( kCDROMOptionKey, &optionKey, &bootInfo->bootConfig )) { // The key specified is a special key. - } else if (getValueForKey( kCDROMOptionKey, &val, &cnt, &bootInfo->bootConfig ) && cnt >= 1) { - optionKey = val[0]; } else { // Default to F8. optionKey = 0x4200; @@ -808,7 +805,7 @@ key = optionKey; } - if (cnt) { + if (prompt != NULL) { free(prompt); } @@ -860,7 +857,7 @@ // Associate a menu item for each BVRef. for (bvr=bvChain, i=gDeviceCount-1, selectIndex=0; bvr; bvr=bvr->next) { if (bvr->visible) { - getBootVolumeDescription(bvr, menuItems[i].name, 80, true); + getBootVolumeDescription(bvr, menuItems[i].name, sizeof(menuItems[i].name) - 1, true); menuItems[i].param = (void *) bvr; if (bvr == menuBVR) { selectIndex = i; @@ -1136,8 +1133,6 @@ const char * cp = gBootArgs; const char * val = 0; const char * kernel; - const char *value; - int len; int cnt; int userCnt; int cntRemaining; @@ -1146,7 +1141,6 @@ bool uuidSet = false; char * configKernelFlags; char * valueBuffer; - config_file_t systemVersion; valueBuffer = malloc(VALUE_SIZE); @@ -1180,18 +1174,9 @@ else return -1; - // Needed here to enable search for override Boot.plist on OS specific folders. + // Moved here to enable search for override Boot.plist on OS specific folders. // Find out which Mac OS version we're booting. - if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion)) - { - if (getValueForKey(kProductVersion, &value, &len, &systemVersion)) - { - // getValueForKey uses const char for val - // so copy it and trim - strncpy(gMacOSVersion, value, MIN(len, 4)); - gMacOSVersion[MIN(len, 4)] = '\0'; - } - } + getOSVersion(gMacOSVersion); //Azi: implemented at loadOverrideConfig. // Load config table specified by the user, or use the default. @@ -1327,31 +1312,62 @@ strncpy(&argP[cnt], cp, userCnt); argP[cnt+userCnt] = '\0'; - if(!shouldboot) + if(!shouldboot) { gVerboseMode = getValueForKey( kVerboseModeFlag, &val, &cnt, &bootInfo->bootConfig ) || getValueForKey( kSingleUserModeFlag, &val, &cnt, &bootInfo->bootConfig ); - + gBootMode = ( getValueForKey( kSafeModeFlag, &val, &cnt, &bootInfo->bootConfig ) ) ? kBootModeSafe : kBootModeNormal; - - if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->bootConfig ) ) { - gBootMode = kBootModeSafe; - } + + if ( getValueForKey( kIgnoreCachesFlag, &val, &cnt, &bootInfo->bootConfig ) ) { + gBootMode = kBootModeSafe; + } } if ( getValueForKey( kMKextCacheKey, &val, &cnt, &bootInfo->bootConfig ) ) { strlcpy(gMKextName, val, cnt + 1); } - + free(configKernelFlags); free(valueBuffer); return 0; } +static bool getOSVersion(char *str) //Azi: moved from boot.c +{ + bool valid = false; + config_file_t systemVersion; + const char *val; + int len; + if (!loadConfigFile("/System/Library/CoreServices/SystemVersion.plist", &systemVersion)) + { //Azi: so, is this path on selected or current volume?? + valid = true; + } + else if (!loadConfigFile("/System/Library/CoreServices/ServerVersion.plist", &systemVersion)) + { + valid = true; + } + + if (valid) + { + if (getValueForKey(kProductVersion, &val, &len, &systemVersion)) + { + // getValueForKey uses const char for val + // so copy it and trim + *str = '\0'; + strncat(str, val, min(len, 4)); + } + else + valid = false; + } + + return valid; +} + //========================================================================== // Load the help file and display the file contents on the screen.