mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-31 23:08:26 -04:00
[syslinux] fix tails breakage and add support for fine grained versions
* With that obscene an amount of pre-releases of 6.03 (seriously, how many more YEARS pre-release of the same version do you actually need?), of course the syslinux people have managed to break the last remnants of compatibility they had between a single major version, so we are now forced to provide a smorgasbord of pre-release and out of band syslinux binaries on our server, and make sure we detect and handle incompatible syslinux versions clientside... For instance, even after fixing the EFI vs isolinux issue, we find that tails 1.1 is incompatible with 'pre19'. But it also uses its own '20131220' extended identifier, instead of 'pre1', its closest relative. So we have to multiply files and symbolic links to try to keep everybody happy. Talk about a MAJOR LETDOWN from the syslinux project... * Closes #363
This commit is contained in:
parent
60c66ef813
commit
0fceb38433
7 changed files with 167 additions and 75 deletions
39
src/iso.c
39
src/iso.c
|
@ -471,7 +471,7 @@ out:
|
|||
|
||||
BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
|
||||
{
|
||||
size_t i, k, size;
|
||||
size_t i, size;
|
||||
int j;
|
||||
uint16_t sl_version;
|
||||
FILE* fd;
|
||||
|
@ -480,11 +480,10 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
|
|||
udf_t* p_udf = NULL;
|
||||
udf_dirent_t* p_udf_root;
|
||||
LONG progress_style;
|
||||
char *tmp, *buf;
|
||||
char *tmp, *buf, *ext;
|
||||
char path[MAX_PATH];
|
||||
const char* basedir[] = { "i386", "minint" };
|
||||
const char* tmp_sif = ".\\txtsetup.sif~";
|
||||
const char ISOLINUX[] = { 'I', 'S', 'O', 'L', 'I', 'N', 'U', 'X', ' ' };
|
||||
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
|
||||
|
||||
if ((!enable_iso) || (src_iso == NULL) || (dest_dir == NULL))
|
||||
|
@ -589,7 +588,12 @@ out:
|
|||
if (!IsStrArrayEmpty(config_path)) {
|
||||
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[0]);
|
||||
for (i=1; i<config_path.Index; i++) {
|
||||
if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.String[i]))
|
||||
// Tails uses an '/EFI/BOOT/isolinux.cfg' along with a '/isolinux/isolinux.cfg'
|
||||
// which are the exact same length. However, only the /isolinux one will work,
|
||||
// so for now, at equal length, always pick the latest.
|
||||
// We may have to revisit this and prefer a path that contains '/isolinux' if
|
||||
// this hack is not enough for other images.
|
||||
if (safe_strlen(iso_report.cfg_path) >= safe_strlen(config_path.String[i]))
|
||||
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[i]);
|
||||
}
|
||||
uprintf("Will use %s for Syslinux\n", iso_report.cfg_path);
|
||||
|
@ -608,20 +612,15 @@ out:
|
|||
}
|
||||
fread(buf, 1, size, fd);
|
||||
fclose(fd);
|
||||
for (k=0; k<size-16; k++) {
|
||||
if (memcmp(&buf[k], ISOLINUX, sizeof(ISOLINUX)) == 0) {
|
||||
k += sizeof(ISOLINUX);
|
||||
sl_version = (((uint8_t)strtoul(&buf[k], &tmp, 10))<<8) + (uint8_t)strtoul(&tmp[1], NULL, 10);
|
||||
if (iso_report.sl_version == 0) {
|
||||
iso_report.sl_version = sl_version;
|
||||
j = (int)i;
|
||||
} else if (iso_report.sl_version != sl_version) {
|
||||
uprintf("Found conflicting %s versions:\n '%s' (%d.%02d) vs '%s' (%d.%02d)\n", isolinux_bin,
|
||||
isolinux_path.String[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version),
|
||||
isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version));
|
||||
}
|
||||
break;
|
||||
}
|
||||
sl_version = GetSyslinuxVersion(buf, size, &ext);
|
||||
if (iso_report.sl_version == 0) {
|
||||
safe_strcpy(iso_report.sl_version_ext, sizeof(iso_report.sl_version_ext), ext);
|
||||
iso_report.sl_version = sl_version;
|
||||
j = (int)i;
|
||||
} else if ((iso_report.sl_version != sl_version) || (safe_strcmp(iso_report.sl_version_ext, ext) != 0)) {
|
||||
uprintf("Found conflicting %s versions:\n '%s' (%d.%02d%s) vs '%s' (%d.%02d%s)\n", isolinux_bin,
|
||||
isolinux_path.String[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version),
|
||||
iso_report.sl_version_ext, isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version), ext);
|
||||
}
|
||||
free(buf);
|
||||
_unlink(dot_isolinux_bin);
|
||||
|
@ -630,8 +629,8 @@ out:
|
|||
if (iso_report.sl_version != 0) {
|
||||
static_sprintf(iso_report.sl_version_str, "%d.%02d",
|
||||
SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version));
|
||||
uprintf("Detected Isolinux version: %s (from '%s')",
|
||||
iso_report.sl_version_str, isolinux_path.String[j]);
|
||||
uprintf("Detected Isolinux version: %s%s (from '%s')",
|
||||
iso_report.sl_version_str, iso_report.sl_version_ext, isolinux_path.String[j]);
|
||||
if ( (has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) < 5))
|
||||
|| (!has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) >= 5)) )
|
||||
uprintf("Warning: Conflict between Isolinux version and the presence of ldlinux.c32...\n");
|
||||
|
|
26
src/net.c
26
src/net.c
|
@ -41,6 +41,9 @@
|
|||
/* Default delay between update checks (1 day) */
|
||||
#define DEFAULT_UPDATE_INTERVAL (24*3600)
|
||||
|
||||
DWORD DownloadStatus;
|
||||
BOOL PromptOnError = TRUE;
|
||||
|
||||
extern BOOL force_update;
|
||||
static DWORD error_code;
|
||||
static BOOL update_check_in_progress = FALSE;
|
||||
|
@ -243,7 +246,7 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog)
|
|||
{
|
||||
HWND hProgressBar = NULL;
|
||||
BOOL r = FALSE;
|
||||
DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize, dwStatus;
|
||||
DWORD dwFlags, dwSize, dwDownloaded, dwTotalSize;
|
||||
FILE* fd = NULL;
|
||||
LONG progress_style;
|
||||
const char* accept_types[] = {"*/*\0", NULL};
|
||||
|
@ -255,6 +258,7 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog)
|
|||
size_t last_slash;
|
||||
int i;
|
||||
|
||||
DownloadStatus = 0;
|
||||
if (hProgressDialog != NULL) {
|
||||
// Use the progress control provided, if any
|
||||
hProgressBar = GetDlgItem(hProgressDialog, IDC_PROGRESS);
|
||||
|
@ -320,12 +324,12 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog)
|
|||
}
|
||||
|
||||
// Get the file size
|
||||
dwSize = sizeof(dwStatus);
|
||||
dwStatus = 404;
|
||||
HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwStatus, &dwSize, NULL);
|
||||
if (dwStatus != 200) {
|
||||
dwSize = sizeof(DownloadStatus);
|
||||
DownloadStatus = 404;
|
||||
HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&DownloadStatus, &dwSize, NULL);
|
||||
if (DownloadStatus != 200) {
|
||||
error_code = ERROR_INTERNET_ITEM_NOT_FOUND;
|
||||
uprintf("Unable to access file: Server status %d\n", dwStatus);
|
||||
uprintf("Unable to access file: Server status %d\n", DownloadStatus);
|
||||
goto out;
|
||||
}
|
||||
dwSize = sizeof(dwTotalSize);
|
||||
|
@ -373,10 +377,12 @@ out:
|
|||
if (fd != NULL) fclose(fd);
|
||||
if (!r) {
|
||||
_unlink(file);
|
||||
PrintStatus(0, FALSE, MSG_242);
|
||||
SetLastError(error_code);
|
||||
MessageBoxU(hMainDialog, IS_ERROR(FormatStatus)?StrError(FormatStatus, FALSE):WinInetErrorString(),
|
||||
lmprintf(MSG_044), MB_OK|MB_ICONERROR|MB_IS_RTL);
|
||||
if (PromptOnError) {
|
||||
PrintStatus(0, FALSE, MSG_242);
|
||||
SetLastError(error_code);
|
||||
MessageBoxU(hMainDialog, IS_ERROR(FormatStatus)?StrError(FormatStatus, FALSE):WinInetErrorString(),
|
||||
lmprintf(MSG_044), MB_OK|MB_ICONERROR|MB_IS_RTL);
|
||||
}
|
||||
}
|
||||
if (hRequest) InternetCloseHandle(hRequest);
|
||||
if (hConnection) InternetCloseHandle(hConnection);
|
||||
|
|
51
src/rufus.c
51
src/rufus.c
|
@ -125,6 +125,7 @@ BOOL enable_HDDs = FALSE, advanced_mode = TRUE, force_update = FALSE, use_fake_u
|
|||
int dialog_showing = 0;
|
||||
uint16_t rufus_version[4], embedded_sl_version[2];
|
||||
char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
|
||||
char embedded_sl_version_ext[2][32];
|
||||
RUFUS_UPDATE update = { {0,0,0,0}, {0,0}, NULL, NULL};
|
||||
StrArray DriveID, DriveLabel;
|
||||
extern char szStatusMessage[256];
|
||||
|
@ -1065,13 +1066,13 @@ void ToggleImage(BOOL enable)
|
|||
static BOOL BootCheck(void)
|
||||
{
|
||||
int i, fs, bt, dt, r;
|
||||
FILE* fd;
|
||||
FILE *fd;
|
||||
DWORD len;
|
||||
BOOL in_files_dir = FALSE;
|
||||
const char* ldlinux = "ldlinux";
|
||||
const char* syslinux = "syslinux";
|
||||
const char* ldlinux_ext[3] = { "sys", "bss", "c32" };
|
||||
char tmp[MAX_PATH];
|
||||
char tmp[MAX_PATH], tmp2[MAX_PATH];
|
||||
|
||||
syslinux_ldlinux_len[0] = 0; syslinux_ldlinux_len[1] = 0;
|
||||
dt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
||||
|
@ -1174,7 +1175,8 @@ static BOOL BootCheck(void)
|
|||
IGNORE_RETVAL(_chdir(FILES_DIR));
|
||||
for (i=0; i<2; i++) {
|
||||
// Check if we already have the relevant ldlinux_v#.##.sys & ldlinux_v#.##.bss files
|
||||
static_sprintf(tmp, "%s-%s/%s.%s", syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]);
|
||||
static_sprintf(tmp, "%s-%s%s/%s.%s", syslinux, iso_report.sl_version_str,
|
||||
iso_report.sl_version_ext, ldlinux, ldlinux_ext[i]);
|
||||
fd = fopen(tmp, "rb");
|
||||
if (fd != NULL) {
|
||||
fseek(fd, 0, SEEK_END);
|
||||
|
@ -1183,21 +1185,46 @@ static BOOL BootCheck(void)
|
|||
}
|
||||
}
|
||||
if ((syslinux_ldlinux_len[0] != 0) && (syslinux_ldlinux_len[1] != 0)) {
|
||||
uprintf("Will reuse '%s.%s' and '%s.%s' from './" FILES_DIR "/%s/%s-%s/' for Syslinux installation\n",
|
||||
ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux, iso_report.sl_version_str);
|
||||
uprintf("Will reuse '%s.%s' and '%s.%s' from './" FILES_DIR "/%s/%s-%s%s/' for Syslinux installation\n",
|
||||
ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux,
|
||||
iso_report.sl_version_str, iso_report.sl_version_ext);
|
||||
} else {
|
||||
r = MessageBoxU(hMainDialog, lmprintf(MSG_114, iso_report.sl_version_str, embedded_sl_version_str[1]),
|
||||
r = MessageBoxU(hMainDialog, lmprintf(MSG_114, iso_report.sl_version_str, iso_report.sl_version_ext,
|
||||
embedded_sl_version_str[1]),
|
||||
lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL);
|
||||
if (r != IDYES)
|
||||
return FALSE;
|
||||
for (i=0; i<2; i++) {
|
||||
static_sprintf(tmp, "%s-%s", syslinux, iso_report.sl_version_str);
|
||||
IGNORE_RETVAL(_mkdir(tmp));
|
||||
if (*iso_report.sl_version_ext != 0) {
|
||||
IGNORE_RETVAL(_chdir(tmp));
|
||||
IGNORE_RETVAL(_mkdir(&iso_report.sl_version_ext[1]));
|
||||
IGNORE_RETVAL(_chdir(".."));
|
||||
}
|
||||
static_sprintf(tmp, "%s.%s %s", ldlinux, ldlinux_ext[i], iso_report.sl_version_str);
|
||||
SetWindowTextU(hISOProgressDlg, lmprintf(MSG_085, tmp));
|
||||
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]);
|
||||
static_sprintf(tmp, "%s/%s-%s%s/%s.%s", FILES_URL, syslinux, iso_report.sl_version_str,
|
||||
iso_report.sl_version_ext, ldlinux, ldlinux_ext[i]);
|
||||
SetWindowTextU(hISOFileName, tmp);
|
||||
PromptOnError = (*iso_report.sl_version_ext == 0);
|
||||
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hISOProgressDlg);
|
||||
PromptOnError = TRUE;
|
||||
if ((syslinux_ldlinux_len[i] == 0) && (DownloadStatus == 404) && (*iso_report.sl_version_ext != 0)) {
|
||||
// Couldn't locate the file on the server => try to download without the version extra
|
||||
uprintf("Extended version was not found, trying main version\n");
|
||||
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, iso_report.sl_version_str,
|
||||
ldlinux, ldlinux_ext[i]);
|
||||
SetWindowTextU(hISOFileName, tmp);
|
||||
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hISOProgressDlg);
|
||||
if (syslinux_ldlinux_len[i] != 0) {
|
||||
// Duplicate the file so that the user won't be prompted to download again
|
||||
static_sprintf(tmp, "%s-%s\\%s.%s", syslinux, iso_report.sl_version_str, ldlinux, ldlinux_ext[i]);
|
||||
static_sprintf(tmp2, "%s-%s\\%s\\%s.%s", syslinux, iso_report.sl_version_str,
|
||||
&iso_report.sl_version_ext[1], ldlinux, ldlinux_ext[i]);
|
||||
CopyFileA(tmp, tmp2, FALSE);
|
||||
}
|
||||
}
|
||||
if (syslinux_ldlinux_len[i] == 0) {
|
||||
uprintf("Couldn't download the files - cancelling\n");
|
||||
return FALSE;
|
||||
|
@ -1249,7 +1276,7 @@ void InitDialog(HWND hDlg)
|
|||
DWORD len;
|
||||
HDC hDC;
|
||||
int i, i16, s16;
|
||||
char tmp[128], *token, *buf;
|
||||
char tmp[128], *token, *buf, *ext;
|
||||
static char* resource[2] = { MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V5_SYS) };
|
||||
|
||||
#ifdef RUFUS_TEST
|
||||
|
@ -1301,14 +1328,16 @@ void InitDialog(HWND hDlg)
|
|||
uprintf(APPLICATION_NAME " version: %d.%d.%d.%d\n", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]);
|
||||
for (i=0; i<ARRAYSIZE(resource); i++) {
|
||||
buf = (char*)GetResource(hMainInstance, resource[i], _RT_RCDATA, "ldlinux_sys", &len, FALSE);
|
||||
if ((buf == NULL) || (len < 16)) {
|
||||
if (buf == NULL) {
|
||||
uprintf("Warning: could not read embedded Syslinux v%d version", i+4);
|
||||
} else {
|
||||
embedded_sl_version[i] = (((uint8_t)strtoul(&buf[0xb], &token, 10))<<8) + (uint8_t)strtoul(&token[1], NULL, 10);
|
||||
embedded_sl_version[i] = GetSyslinuxVersion(buf, len, &ext);
|
||||
static_sprintf(embedded_sl_version_str[i], "%d.%02d", SL_MAJOR(embedded_sl_version[i]), SL_MINOR(embedded_sl_version[i]));
|
||||
safe_strcpy(embedded_sl_version_ext[i], sizeof(embedded_sl_version_ext[i]), ext);
|
||||
}
|
||||
}
|
||||
uprintf("Syslinux versions: %s, %s", embedded_sl_version_str[0], embedded_sl_version_str[1]);
|
||||
uprintf("Syslinux versions: %s%s, %s%s", embedded_sl_version_str[0], embedded_sl_version_ext[0],
|
||||
embedded_sl_version_str[1], embedded_sl_version_ext[1]);
|
||||
uprintf("Windows version: %s\n", WindowsVersionStr);
|
||||
uprintf("Locale ID: 0x%04X\n", GetUserDefaultUILanguage());
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@ typedef struct {
|
|||
BOOL is_vhd;
|
||||
uint16_t sl_version; // Syslinux/Isolinux version
|
||||
char sl_version_str[12];
|
||||
char sl_version_ext[32];
|
||||
} RUFUS_ISO_REPORT;
|
||||
|
||||
/* Isolate the Syslinux version numbers */
|
||||
|
@ -319,7 +320,8 @@ extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName, hDiskID;
|
|||
extern float fScale;
|
||||
extern char szFolderPath[MAX_PATH], app_dir[MAX_PATH];
|
||||
extern char* image_path;
|
||||
extern DWORD FormatStatus;
|
||||
extern DWORD FormatStatus, DownloadStatus;
|
||||
extern BOOL PromptOnError;
|
||||
extern DWORD syslinux_ldlinux_len[2];
|
||||
extern RUFUS_DRIVE_INFO SelectedDrive;
|
||||
extern const int nb_steps[FS_MAX];
|
||||
|
@ -363,6 +365,7 @@ extern BOOL ExtractDOS(const char* path);
|
|||
extern BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan);
|
||||
extern int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file, DWORD attributes);
|
||||
extern BOOL InstallSyslinux(DWORD drive_index, char drive_letter);
|
||||
extern uint16_t GetSyslinuxVersion(char* buf, size_t buf_size, char** ext);
|
||||
extern BOOL CreateProgress(void);
|
||||
extern BOOL SetAutorun(const char* path);
|
||||
extern char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options);
|
||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
|
||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Rufus 1.4.10.508"
|
||||
CAPTION "Rufus 1.4.10.509"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -165,7 +165,7 @@ END
|
|||
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
|
||||
CAPTION "Rufus 1.4.10.508"
|
||||
CAPTION "Rufus 1.4.10.509"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||
|
@ -428,8 +428,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,4,10,508
|
||||
PRODUCTVERSION 1,4,10,508
|
||||
FILEVERSION 1,4,10,509
|
||||
PRODUCTVERSION 1,4,10,509
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -446,13 +446,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.4.10.508"
|
||||
VALUE "FileVersion", "1.4.10.509"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.4.10.508"
|
||||
VALUE "ProductVersion", "1.4.10.509"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -109,7 +109,8 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter)
|
|||
syslinux_ldlinux[i] = (unsigned char*) malloc(syslinux_ldlinux_len[i]);
|
||||
if (syslinux_ldlinux[i] == NULL)
|
||||
goto out;
|
||||
static_sprintf(path, "%s/%s-%s/%s.%s", FILES_DIR, syslinux, iso_report.sl_version_str, ldlinux, i==0?"sys":"bss");
|
||||
static_sprintf(path, "%s/%s-%s%s/%s.%s", FILES_DIR, syslinux, iso_report.sl_version_str,
|
||||
iso_report.sl_version_ext, ldlinux, i==0?"sys":"bss");
|
||||
fd = fopen(path, "rb");
|
||||
if (fd == NULL) {
|
||||
uprintf("Could not open %s\n", path);
|
||||
|
@ -300,3 +301,57 @@ out:
|
|||
safe_closehandle(f_handle);
|
||||
return r;
|
||||
}
|
||||
|
||||
uint16_t GetSyslinuxVersion(char* buf, size_t buf_size, char** ext)
|
||||
{
|
||||
size_t i, j;
|
||||
char *p;
|
||||
uint16_t version;
|
||||
const char LINUX[] = { 'L', 'I', 'N', 'U', 'X', ' ' };
|
||||
static char* nullstr = "";
|
||||
|
||||
*ext = nullstr;
|
||||
if (buf_size < 256)
|
||||
return 0;
|
||||
|
||||
// Start at 64 to avoid the short incomplete version at the beginning of ldlinux.sys
|
||||
for (i=64; i<buf_size-64; i++) {
|
||||
if (memcmp(&buf[i], LINUX, sizeof(LINUX)) == 0) {
|
||||
// Check for ISO or SYS prefix
|
||||
if (!( ((buf[i-3] == 'I') && (buf[i-2] == 'S') && (buf[i-1] == 'O'))
|
||||
|| ((buf[i-3] == 'S') && (buf[i-2] == 'Y') && (buf[i-1] == 'S')) ))
|
||||
continue;
|
||||
i += sizeof(LINUX);
|
||||
version = (((uint8_t)strtoul(&buf[i], &p, 10))<<8) + (uint8_t)strtoul(&p[1], &p, 10);
|
||||
if (version == 0)
|
||||
continue;
|
||||
p[safe_strlen(p)] = 0;
|
||||
// Ensure that our extra version string starts with a slash
|
||||
*p = '/';
|
||||
// Remove the x.yz- duplicate if present
|
||||
for (j=0; (buf[i+j] == p[1+j]) && (buf[i+j] != ' '); j++);
|
||||
if (p[j+1] == '-')
|
||||
j++;
|
||||
if (j >= 4) {
|
||||
p[j] = '/';
|
||||
p = &p[j];
|
||||
}
|
||||
for (j=safe_strlen(p)-1; j>0; j--) {
|
||||
// Arch Linux affixes a star for their version - who knows what else is out there...
|
||||
if ((p[j] == ' ') || (p[j] == '*'))
|
||||
p[j] = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
// Sanitize the string
|
||||
for (j=1; j<safe_strlen(p); j++)
|
||||
// Some people are bound to have slashes in their date strings
|
||||
if ((p[j] == '/') || (p[j] == '\\') || (p[j] == '*'))
|
||||
p[j] = '_';
|
||||
// If all we have is a slash, return the empty string for the extra version
|
||||
*ext = (p[1] == 0)?nullstr:p;
|
||||
return version;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue