From 1ebcd68f0d60c05dad0b9b1557f789b92b74a640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 4 Jan 2015 23:49:18 +0000 Subject: [PATCH] [FREELDR] - Correctly append a backslash to the BootPath (if needed). - Be able to specify relative boot paths (relative to the current boot device): as a consequence, remove the "LiveCD" hackish special value that was introduced long long ago. - Fix BootPath retrieval in ReactOSSetup mode (via the SystemPath optional value), and use a better way to build the temporary txtsetup.sif full file names. As a consequence we can now build hybrid cds with the following architecture: \ --> loader\ (bootsectors + free/setupldr.sys) --> myboot\ (contents of what_defaults_to_reactos directory for the bootcd) --> mylive\ (contents of what_defaults_to_reactos directory for the livecd) --> and freeldr.ini specifying the following values: ; The Setup entry [Setup] BootType=ReactOSSetup SystemPath=\myboot ; The LiveCD entry [LiveCD] BootType=Windows2003 SystemPath=\mylive Options=/MININT Part 2/2 CORE-9023 svn path=/trunk/; revision=65982 --- reactos/boot/bootdata/livecd.ini | 8 ++-- reactos/boot/freeldr/freeldr/CHANGELOG | 6 +++ .../boot/freeldr/freeldr/windows/setupldr.c | 38 +++++++++++++++---- reactos/boot/freeldr/freeldr/windows/winldr.c | 24 +++++++++--- 4 files changed, 60 insertions(+), 16 deletions(-) diff --git a/reactos/boot/bootdata/livecd.ini b/reactos/boot/bootdata/livecd.ini index 6a208ce87e0..3d9feb6dae9 100644 --- a/reactos/boot/bootdata/livecd.ini +++ b/reactos/boot/bootdata/livecd.ini @@ -32,20 +32,20 @@ LiveCD_LogFile="LiveCD (Log file)" [LiveCD] BootType=Windows2003 -SystemPath=LiveCD\reactos +SystemPath=\reactos Options=/MININT [LiveCD_Debug] BootType=Windows2003 -SystemPath=LiveCD\reactos +SystemPath=\reactos Options=/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /MININT [LiveCD_Screen] BootType=Windows2003 -SystemPath=LiveCD\reactos +SystemPath=\reactos Options=/DEBUG /DEBUGPORT=SCREEN /SOS /MININT [LiveCD_LogFile] BootType=Windows2003 -SystemPath=LiveCD\reactos +SystemPath=\reactos Options=/DEBUG /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log /SOS /MININT diff --git a/reactos/boot/freeldr/freeldr/CHANGELOG b/reactos/boot/freeldr/freeldr/CHANGELOG index c97c1dd56d6..9b17b46b3c5 100644 --- a/reactos/boot/freeldr/freeldr/CHANGELOG +++ b/reactos/boot/freeldr/freeldr/CHANGELOG @@ -1,3 +1,9 @@ +Changes in v3.0+ (05/01/2015) (hbelusca) + +- Remove support for special value "LiveCD" of SystemPath option + for loading ReactOS since now we treat non-ARC SystemPath as + a path relative to the boot path. + Changes in v3.0.0 (11/12/2007) (fball) - Support for building an ARC Tree. diff --git a/reactos/boot/freeldr/freeldr/windows/setupldr.c b/reactos/boot/freeldr/freeldr/windows/setupldr.c index 18d2de64610..1367b09abd0 100644 --- a/reactos/boot/freeldr/freeldr/windows/setupldr.c +++ b/reactos/boot/freeldr/freeldr/windows/setupldr.c @@ -178,17 +178,40 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, HasSection = IniOpenSection(SectionName, &SectionId); UiDrawBackdrop(); - UiDrawProgressBarCenter(1, 100, "Loading NT..."); + UiDrawProgressBarCenter(1, 100, "Loading ReactOS Setup..."); /* Read the system path is set in the .ini file */ if (!HasSection || !IniReadSettingByName(SectionId, "SystemPath", BootPath, sizeof(BootPath))) { - MachDiskGetBootPath(BootPath, sizeof(BootPath)); + // MachDiskGetBootPath(BootPath, sizeof(BootPath)); + // strcpy(BootPath, SectionName); } - /* Append a backslash */ - if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\') + /* + * Check whether BootPath is a full path + * and if not, create a full boot path. + * + * See FsOpenFile for the technique used. + */ + if (strrchr(BootPath, ')') == NULL) + { + /* Temporarily save the boot path */ + strcpy(FileName, BootPath); + + /* This is not a full path. Use the current (i.e. boot) device. */ + MachDiskGetBootPath(BootPath, sizeof(BootPath)); + + /* Append a path separator if needed */ + if (FileName[0] != '\\' && FileName[0] != '/') + strcat(BootPath, "\\"); + + /* Append the remaining path */ + strcat(BootPath, FileName); + } + + /* Append a backslash if needed */ + if ((strlen(BootPath) == 0) || BootPath[strlen(BootPath) - 1] != '\\') strcat(BootPath, "\\"); /* Read booting options */ @@ -233,10 +256,11 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem, ERR("Failed to open txtsetup.sif\n"); return; } - sprintf(File, "%stxtsetup.sif", SystemPath); - if (InfOpenFile (&InfHandle, BootPath, &ErrorLine)) + strcpy(File, SystemPath); + strcpy(FileName, BootPath); + strcat(FileName, "txtsetup.sif"); + if (InfOpenFile(&InfHandle, FileName, &ErrorLine)) { - sprintf(File, "%s", SystemPath); break; } } diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index d31303791e3..cf772c74a4c 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -621,16 +621,30 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, strcpy(BootPath, SectionName); } - /* Special case for LiveCD */ - if (!_strnicmp(BootPath, "LiveCD", strlen("LiveCD"))) + /* + * Check whether BootPath is a full path + * and if not, create a full boot path. + * + * See FsOpenFile for the technique used. + */ + if (strrchr(BootPath, ')') == NULL) { - strcpy(FileName, BootPath + strlen("LiveCD")); + /* Temporarily save the boot path */ + strcpy(FileName, BootPath); + + /* This is not a full path. Use the current (i.e. boot) device. */ MachDiskGetBootPath(BootPath, sizeof(BootPath)); + + /* Append a path separator if needed */ + if (FileName[0] != '\\' && FileName[0] != '/') + strcat(BootPath, "\\"); + + /* Append the remaining path */ strcat(BootPath, FileName); } - /* Append a backslash */ - if ((strlen(BootPath)==0) || BootPath[strlen(BootPath)] != '\\') + /* Append a backslash if needed */ + if ((strlen(BootPath) == 0) || BootPath[strlen(BootPath) - 1] != '\\') strcat(BootPath, "\\"); /* Read booting options */