1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[syslinux] improve support for Syslinux based Slax ISOs

* For some weird reason appending the base directory to the root syslinux.cfg
  we create does not appear to work with Slax. So we now always patch ldlinux.sys
  to include the base directory.
* Also add an exception to move the /slax/boot/EFI directory to /EFI.
* It should be noted that, as of slax-64bit-slackware-15.0.3.iso, the Slax UEFI
  Syslinux bootloaders appear to be broken (since creating a media without using
  Rufus at all per the Slax documentation does *not* produce a USB drive that was
  bootable in UEFI mode on 2 of the machines I tried).
* Also clean up some iso.c code and fix some unreachable code in ntfssect.c.
* Closes #2336.
* Closes #2338.
This commit is contained in:
Pete Batard 2023-10-11 20:46:46 +01:00
parent 45a5f22d43
commit 0bd38abd4e
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
5 changed files with 44 additions and 24 deletions

View file

@ -1096,7 +1096,7 @@ out:
if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0)) if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0))
img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size; img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size;
// Remove trailing spaces from the label // Remove trailing spaces from the label
for (k=(int)safe_strlen(img_report.label)-1; ((k>0)&&(isspaceU(img_report.label[k]))); k--) for (k = (int)safe_strlen(img_report.label) - 1; ((k > 0) && (isspaceU(img_report.label[k]))); k--)
img_report.label[k] = 0; img_report.label[k] = 0;
// We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here // We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here
img_report.projected_size = total_blocks * ISO_BLOCKSIZE; img_report.projected_size = total_blocks * ISO_BLOCKSIZE;
@ -1106,9 +1106,9 @@ out:
if (!IsStrArrayEmpty(config_path)) { if (!IsStrArrayEmpty(config_path)) {
// Set the img_report.cfg_path string to maximum length, so that we don't have to // Set the img_report.cfg_path string to maximum length, so that we don't have to
// do a special case for StrArray entry 0. // do a special case for StrArray entry 0.
memset(img_report.cfg_path, '_', sizeof(img_report.cfg_path)-1); memset(img_report.cfg_path, '_', sizeof(img_report.cfg_path) - 1);
img_report.cfg_path[sizeof(img_report.cfg_path)-1] = 0; img_report.cfg_path[sizeof(img_report.cfg_path) - 1] = 0;
for (i=0; i<config_path.Index; i++) { for (i = 0; i < config_path.Index; i++) {
// OpenSuse based Live image have a /syslinux.cfg that doesn't work, so we enforce // OpenSuse based Live image have a /syslinux.cfg that doesn't work, so we enforce
// the use of the one in '/boot/[i386|x86_64]/loader/isolinux.cfg' if present. // the use of the one in '/boot/[i386|x86_64]/loader/isolinux.cfg' if present.
// Note that, because the openSuse live script are not designed to handle anything but // Note that, because the openSuse live script are not designed to handle anything but
@ -1130,7 +1130,7 @@ out:
} }
uprintf(" Will use '%s' for Syslinux", img_report.cfg_path); uprintf(" Will use '%s' for Syslinux", img_report.cfg_path);
// Extract all of the isolinux.bin files we found to identify their versions // Extract all of the isolinux.bin files we found to identify their versions
for (i=0; i<isolinux_path.Index; i++) { for (i = 0; i < isolinux_path.Index; i++) {
char isolinux_tmp[MAX_PATH]; char isolinux_tmp[MAX_PATH];
static_sprintf(isolinux_tmp, "%sisolinux.tmp", temp_dir); static_sprintf(isolinux_tmp, "%sisolinux.tmp", temp_dir);
size = (size_t)ExtractISOFile(src_iso, isolinux_path.String[i], isolinux_tmp, FILE_ATTRIBUTE_NORMAL); size = (size_t)ExtractISOFile(src_iso, isolinux_path.String[i], isolinux_tmp, FILE_ATTRIBUTE_NORMAL);
@ -1157,7 +1157,7 @@ out:
img_report.sl_version_ext, isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version), ext); img_report.sl_version_ext, isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version), ext);
// Workaround for Antergos and other ISOs, that have multiple Syslinux versions. // Workaround for Antergos and other ISOs, that have multiple Syslinux versions.
// Where possible, prefer to the one that resides in the same directory as the config file. // Where possible, prefer to the one that resides in the same directory as the config file.
for (j=safe_strlen(img_report.cfg_path); (j>0) && (img_report.cfg_path[j]!='/'); j--); for (j=safe_strlen(img_report.cfg_path); (j > 0) && (img_report.cfg_path[j] != '/'); j--);
if (safe_strnicmp(img_report.cfg_path, isolinux_path.String[i], j) == 0) { if (safe_strnicmp(img_report.cfg_path, isolinux_path.String[i], j) == 0) {
static_strcpy(img_report.sl_version_ext, ext); static_strcpy(img_report.sl_version_ext, ext);
img_report.sl_version = sl_version; img_report.sl_version = sl_version;
@ -1197,7 +1197,7 @@ out:
ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL); ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL);
tmp = get_token_data_file("OsLoadOptions", tmp_sif); tmp = get_token_data_file("OsLoadOptions", tmp_sif);
if (tmp != NULL) { if (tmp != NULL) {
for (i=0; i<strlen(tmp); i++) for (i = 0; i < strlen(tmp); i++)
tmp[i] = (char)tolower(tmp[i]); tmp[i] = (char)tolower(tmp[i]);
uprintf(" Checking txtsetup.sif:\n OsLoadOptions = %s", tmp); uprintf(" Checking txtsetup.sif:\n OsLoadOptions = %s", tmp);
img_report.uses_minint = (strstr(tmp, "/minint") != NULL); img_report.uses_minint = (strstr(tmp, "/minint") != NULL);
@ -1308,6 +1308,19 @@ out:
// bootmgr might need to be uncompressed: https://github.com/pbatard/rufus/issues/1381 // bootmgr might need to be uncompressed: https://github.com/pbatard/rufus/issues/1381
RunCommand("compact /u bootmgr* efi/boot/*.efi", dest_dir, TRUE); RunCommand("compact /u bootmgr* efi/boot/*.efi", dest_dir, TRUE);
} }
// Exception for Slax Syslinux UEFI bootloaders...
// ...that don't appear to work anyway as of slax-64bit-slackware-15.0.3.iso
static_sprintf(path, "%s\\slax\\boot\\EFI", dest_dir);
if (PathFileExistsA(path)) {
char dst_path[16];
static_sprintf(dst_path, "%s\\EFI", dest_dir);
if (!PathFileExistsA(dst_path)) {
if (MoveFileA(path, dst_path))
uprintf("Moved: %s → %s", path, dst_path);
else
uprintf("Could not move %s → %s", path, dst_path, WindowsErrorString());
}
}
update_md5sum(); update_md5sum();
if (archive_path != NULL) { if (archive_path != NULL) {
uprintf("● Adding files from %s", archive_path); uprintf("● Adding files from %s", archive_path);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.3.2085" CAPTION "Rufus 4.3.2086"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,3,2085,0 FILEVERSION 4,3,2086,0
PRODUCTVERSION 4,3,2085,0 PRODUCTVERSION 4,3,2086,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.3.2085" VALUE "FileVersion", "4.3.2086"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.3.exe" VALUE "OriginalFilename", "rufus-4.3.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.3.2085" VALUE "ProductVersion", "4.3.2086"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -2,7 +2,7 @@
* *
* Copyright 2003 Lars Munch Christensen - All Rights Reserved * Copyright 2003 Lars Munch Christensen - All Rights Reserved
* Copyright 1998-2008 H. Peter Anvin - All Rights Reserved * Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
* Copyright 2012-2021 Pete Batard * Copyright 2012-2023 Pete Batard
* *
* Based on the Linux installer program for SYSLINUX by H. Peter Anvin * Based on the Linux installer program for SYSLINUX by H. Peter Anvin
* *
@ -111,10 +111,10 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
libfat_sector_t *sectors = NULL; libfat_sector_t *sectors = NULL;
int ldlinux_sectors; int ldlinux_sectors;
uint32_t ldlinux_cluster; uint32_t ldlinux_cluster;
int i, nsectors, sl_fs_stype; int i, w, nsectors, sl_fs_stype;
BOOL use_v5 = (boot_type == BT_SYSLINUX_V6) || ((boot_type == BT_IMAGE) && (SL_MAJOR(img_report.sl_version) >= 5)); BOOL use_v5 = (boot_type == BT_SYSLINUX_V6) || ((boot_type == BT_IMAGE) && (SL_MAJOR(img_report.sl_version) >= 5));
PrintInfoDebug(0, MSG_234, (boot_type == BT_IMAGE)?img_report.sl_version_str:embedded_sl_version_str[use_v5?1:0]); PrintInfoDebug(0, MSG_234, (boot_type == BT_IMAGE) ? img_report.sl_version_str : embedded_sl_version_str[use_v5?1:0]);
/* 4K sector size workaround */ /* 4K sector size workaround */
SECTOR_SHIFT = 0; SECTOR_SHIFT = 0;
@ -287,8 +287,14 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
goto out; goto out;
} }
/* Patch ldlinux.sys and the boot sector */ /* Set the base directory and patch ldlinux.sys and the boot sector */
if (syslinux_patch(sectors, nsectors, 0, 0, NULL, NULL) < 0) { for (i = (int)strlen(img_report.cfg_path); (i > 0) && (img_report.cfg_path[i] != '/'); i--);
if (i > 0)
img_report.cfg_path[i] = 0;
w = syslinux_patch(sectors, nsectors, 0, 0, img_report.cfg_path, NULL);
if (i > 0)
img_report.cfg_path[i] = '/';
if (w < 0) {
uprintf("Could not patch Syslinux files."); uprintf("Could not patch Syslinux files.");
uprintf("WARNING: This could be caused by your firewall having modified downloaded content, such as 'ldlinux.sys'..."); uprintf("WARNING: This could be caused by your firewall having modified downloaded content, such as 'ldlinux.sys'...");
goto out; goto out;

View file

@ -28,6 +28,7 @@
#include "syslinux.h" #include "syslinux.h"
#include "syslxint.h" #include "syslxint.h"
extern void uprintf(const char* format, ...);
/* /*
* Generate sector extents * Generate sector extents
@ -161,8 +162,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
#if 0 #if 0
if (nsect > nptrs) { if (nsect > nptrs) {
/* Not necessarily an error in this case, but a general problem */ /* Not necessarily an error in this case, but a general problem */
fprintf(stderr, "Insufficient extent space, build error!\n"); uprintf("syslinux_patch: Insufficient extent space, build error!\n");
exit(1); return -1;
} }
#endif #endif
@ -178,8 +179,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
if (subdir) { if (subdir) {
int sublen = strlen(subdir) + 1; int sublen = strlen(subdir) + 1;
if (get_16_sl(&epa->dirlen) < sublen) { if (get_16_sl(&epa->dirlen) < sublen) {
fprintf(stderr, "Subdirectory path too long... aborting install!\n"); uprintf("syslinux_patch: Subdirectory path too long... aborting install!");
exit(1); return -1;
} }
memcpy_to_sl(slptr(boot_image, &epa->diroffset), subdir, sublen); memcpy_to_sl(slptr(boot_image, &epa->diroffset), subdir, sublen);
} }
@ -188,8 +189,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors,
if (subvol) { if (subvol) {
int sublen = strlen(subvol) + 1; int sublen = strlen(subvol) + 1;
if (get_16_sl(&epa->subvollen) < sublen) { if (get_16_sl(&epa->subvollen) < sublen) {
fprintf(stderr, "Subvol name too long... aborting install!\n"); uprintf("syslinux_patch: Subvol name too long... aborting install!");
exit(1); return -1;
} }
memcpy_to_sl(slptr(boot_image, &epa->subvoloffset), subvol, sublen); memcpy_to_sl(slptr(boot_image, &epa->subvoloffset), subvol, sublen);
} }

View file

@ -126,10 +126,10 @@ static DWORD NtfsSectGetVolumeHandle(
M_ERR("Unable to open volume handle!"); M_ERR("Unable to open volume handle!");
goto err_handle; goto err_handle;
} }
CloseHandle(VolumeInfo->Handle);
return ERROR_SUCCESS; return ERROR_SUCCESS;
CloseHandle(VolumeInfo->Handle);
err_handle: err_handle:
return rc; return rc;