summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2003-11-21 08:09:14 +0000
committerhpa <hpa>2003-11-21 08:09:14 +0000
commitcdf1944cf7bbce0d6f2c290746df9c9d8cf058d6 (patch)
treef75aee390c87ddb387d5be0fc816c7b766dff855
parent4e754168b72c41cd19d9ae1be835e651ab9d402c (diff)
downloadsyslinux-cdf1944cf7bbce0d6f2c290746df9c9d8cf058d6.tar.gz
Updates to the win32 installer [Lars Munch.]syslinux-2.07-pre8
-rw-r--r--NEWS1
-rw-r--r--win32/syslinux-mingw.c80
2 files changed, 29 insertions, 52 deletions
diff --git a/NEWS b/NEWS
index b8bcb742..4c029c36 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 eec0b00f..a71d50df 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 <varargs.h>
-#include <windef.h>
-#include <winbase.h>
-#include <winnt.h>
-#include <wingdi.h>
-#include <winuser.h>
-#include <winioctl.h>
-
-#include <fcntl.h>
+#include <windows.h>
#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <ctype.h>
#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);