From: hpa Date: Fri, 21 Nov 2003 08:09:14 +0000 (+0000) Subject: Updates to the win32 installer [Lars Munch.] X-Git-Tag: syslinux-3.11~508 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdf1944cf7bbce0d6f2c290746df9c9d8cf058d6;p=profile%2Fivi%2Fsyslinux.git Updates to the win32 installer [Lars Munch.] --- diff --git a/NEWS b/NEWS index b8bcb74..4c029c3 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Changes in 2.07: * PXELINUX: Fix multiple bugs in chainloading of other NBPs. * MEMDISK: Fix bug that would occationally cause "ran out of input data" when using compressed disk images. + * SYSLINUX: Updates for the win32 installer (from Lars Munch.) Changes in 2.06: * ALL: Fix problem that would occationally cause a diff --git a/win32/syslinux-mingw.c b/win32/syslinux-mingw.c index eec0b00..a71d50d 100644 --- a/win32/syslinux-mingw.c +++ b/win32/syslinux-mingw.c @@ -13,32 +13,12 @@ * ----------------------------------------------------------------------- */ /* - * syslinux.c - Win2k/WinXP installer program for SYSLINUX - * - * To compile this install Cygwin with gcc, gcc-mingw, w32api, - * nasm, make and perl. Then build with: 'make syslinux.exe' - * - * TODO: - * * Test with harddrives. We might need to use \\.\PHYSICALDRIVEX - * instead of \\.\X: for these non removable devices. + * syslinux-mingw.c - Win2k/WinXP installer program for SYSLINUX */ -#include -#include -#include -#include -#include -#include -#include - -#include +#include #include -#include -#include -#include -#include -#include -#include +#include #include "syslinux.h" @@ -95,10 +75,10 @@ void usage(void) int main(int argc, char *argv[]) { HANDLE f_handle; - DISK_GEOMETRY dg; DWORD bytes_read; DWORD bytes_written; - DWORD junk; + DWORD drives; + UINT drive_type; static unsigned char sectbuf[512]; char **argp, *opt; @@ -141,6 +121,29 @@ int main(int argc, char *argv[]) if ( !drive ) usage(); + /* Test if drive exists */ + drives = GetLogicalDrives(); + if(!(drives & ( 1 << (tolower(drive[0]) - 'a')))) { + fprintf(stderr, "No such drive %c:\n", drive[0]); + exit(1); + } + + /* Determines the drive type */ + sprintf(drive_name, "%c:\\", drive[0]); + drive_type = GetDriveType(drive_name); + + /* Test for removeable media */ + if ((drive_type == DRIVE_FIXED) && (force == 0)) { + fprintf(stderr, "Not a removable drive (use -f to override) \n"); + exit(1); + } + + /* Test for unsupported media */ + if ((drive_type != DRIVE_FIXED) && (drive_type != DRIVE_REMOVABLE)) { + fprintf(stderr, "Unsupported media\n"); + exit(1); + } + /* * First open the drive */ @@ -154,27 +157,6 @@ int main(int argc, char *argv[]) exit(1); } - /* Get drive geometry */ - if(!DeviceIoControl(f_handle, IOCTL_DISK_GET_DRIVE_GEOMETRY, - NULL, 0, &dg, sizeof(dg), - &junk, (LPOVERLAPPED) NULL)) { - - error("GetDriveGeometry failed"); - exit(1); - } - - /* Test for removeable media */ - if ((dg.MediaType == FixedMedia) && (force == 0)) { - fprintf(stderr, "Not a removable drive (use -f to override) \n"); - exit(1); - } - - /* Test for unknown media */ - if ((dg.MediaType == Unknown) && (force == 0)) { - fprintf(stderr, "Drive media unknown (use -f to override) \n"); - exit(1); - } - /* * Read the boot sector */ @@ -201,12 +183,6 @@ int main(int argc, char *argv[]) exit(1); } - /* Now flush the media */ - if(!FlushFileBuffers(f_handle)) { - error("FlushFileBuffers failed"); - exit(1); - } - /* Close file */ CloseHandle(f_handle);