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

[iso] add workaround for ISOs that have a syslinux symbolic link to isolinux

* This is for Knoppix images that have a /boot/syslinux that links to /boot/isolinux/
  with EFI Syslinux trying to use /boot/syslinux/syslnx[32|64].cfg as its config file.
* Note to Knoppix devs, you could have ensured EFI File System transposition by using
  the same approach as we do here, which is to create non-symlinked /boot/syslinux
  config files that point back to the isolinux ones.
This commit is contained in:
Pete Batard 2022-07-08 13:34:34 +01:00
parent f17e287e39
commit 2be4470bc5
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
2 changed files with 56 additions and 7 deletions

View file

@ -125,6 +125,7 @@ static uint8_t joliet_level = 0;
static uint64_t total_blocks, nb_blocks; static uint64_t total_blocks, nb_blocks;
static BOOL scan_only = FALSE; static BOOL scan_only = FALSE;
static StrArray config_path, isolinux_path, modified_path; static StrArray config_path, isolinux_path, modified_path;
static char symlinked_syslinux[MAX_PATH];
// Ensure filenames do not contain invalid FAT32 or NTFS characters // Ensure filenames do not contain invalid FAT32 or NTFS characters
static __inline char* sanitize_filename(char* filename, BOOL* is_identical) static __inline char* sanitize_filename(char* filename, BOOL* is_identical)
@ -789,8 +790,15 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
if (!is_identical) if (!is_identical)
uprintf(" File name sanitized to '%s'", psz_sanpath); uprintf(" File name sanitized to '%s'", psz_sanpath);
if (is_symlink) { if (is_symlink) {
if (file_length == 0) if (file_length == 0) {
uprintf(" Ignoring Rock Ridge symbolic link to '%s'", p_statbuf->rr.psz_symlink); // Special handling for ISOs that have a syslinux → isolinux symbolic link (e.g. Knoppix)
if ((safe_stricmp(p_statbuf->filename, "syslinux") == 0) &&
(safe_stricmp(p_statbuf->rr.psz_symlink, "isolinux") == 0)) {
static_strcpy(symlinked_syslinux, psz_fullpath);
uprintf(" Found Rock Ridge symbolic link to '%s'", p_statbuf->rr.psz_symlink);
} else
uprintf(" Ignoring Rock Ridge symbolic link to '%s'", p_statbuf->rr.psz_symlink);
}
safe_free(p_statbuf->rr.psz_symlink); safe_free(p_statbuf->rr.psz_symlink);
} }
file_handle = CreatePreallocatedFile(psz_sanpath, GENERIC_READ | GENERIC_WRITE, file_handle = CreatePreallocatedFile(psz_sanpath, GENERIC_READ | GENERIC_WRITE,
@ -912,6 +920,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
} }
nb_blocks = 0; nb_blocks = 0;
iso_blocking_status = 0; iso_blocking_status = 0;
symlinked_syslinux[0] = 0;
StrArrayCreate(&modified_path, 8); StrArrayCreate(&modified_path, 8);
} }
@ -1216,6 +1225,46 @@ out:
} }
if (fd != NULL) if (fd != NULL)
fclose(fd); fclose(fd);
// Workaround needed for Knoppix that has a /boot/syslinux that links to /boot/isolinux/
// with EFI Syslinux trying to read /boot/syslinux/syslnx[32|64].cfg as the config file.
if (symlinked_syslinux[0] != 0) {
static const char* efi_cfg_name[] = { "syslnx32.cfg", "syslnx64.cfg" };
size_t len = strlen(symlinked_syslinux);
char isolinux_dir[MAX_PATH];
static_strcpy(isolinux_dir, symlinked_syslinux);
assert(len > 8);
// ".../syslinux" -> ".../isolinux"
isolinux_dir[len - 8] = 'i';
isolinux_dir[len - 7] = 's';
isolinux_dir[len - 6] = 'o';
// Delete the empty syslinux symbolic link remnant and replace it with a syslinux/ dir
DeleteFileA(symlinked_syslinux);
CreateDirectoryA(symlinked_syslinux, NULL);
// Now add the relevant config files that link back to the ones in isolinux/
for (i = 0; i < ARRAYSIZE(efi_cfg_name); i++) {
static_sprintf(path, "%s/%s", isolinux_dir, efi_cfg_name[i]);
if (!PathFileExistsA(path))
continue;
static_sprintf(path, "%s/%s", symlinked_syslinux, efi_cfg_name[i]);
fd = fopen(path, "w");
if (fd == NULL) {
uprintf("Unable to create %s - booting from USB may not work", path);
r = 1;
continue;
}
static_sprintf(path, "%s/%s", isolinux_dir, efi_cfg_name[i]);
fprintf(fd, "DEFAULT loadconfig\n\nLABEL loadconfig\n CONFIG %s\n APPEND %s\n", &path[2], &isolinux_dir[2]);
fclose(fd);
for (j = 0; j < len; j++)
if (symlinked_syslinux[j] == '/')
symlinked_syslinux[j] = '\\';
uprintf("Created: %s\\%s → %s", symlinked_syslinux, efi_cfg_name[i], &path[2]);
for (j = 0; j < len; j++)
if (symlinked_syslinux[j] == '\\')
symlinked_syslinux[j] = '/';
fd = NULL;
}
}
} else if (HAS_BOOTMGR(img_report) && enable_ntfs_compression) { } else if (HAS_BOOTMGR(img_report) && enable_ntfs_compression) {
// 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);

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 3.20.1915" CAPTION "Rufus 3.20.1916"
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
@ -395,8 +395,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,20,1915,0 FILEVERSION 3,20,1916,0
PRODUCTVERSION 3,20,1915,0 PRODUCTVERSION 3,20,1916,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -414,13 +414,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", "3.20.1915" VALUE "FileVersion", "3.20.1916"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2022 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-3.20.exe" VALUE "OriginalFilename", "rufus-3.20.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.20.1915" VALUE "ProductVersion", "3.20.1916"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"