wok-next diff syslinux/stuff/iso2exe/win32.c @ rev 18675
syslinux/taziso: get custom config
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Dec 06 10:57:10 2015 +0100 (2015-12-06) |
parents | ff85ea851c53 |
children | dfbb5425d6ac |
line diff
1.1 --- a/syslinux/stuff/iso2exe/win32.c Mon Apr 01 17:47:04 2013 +0200 1.2 +++ b/syslinux/stuff/iso2exe/win32.c Sun Dec 06 10:57:10 2015 +0100 1.3 @@ -84,10 +84,11 @@ 1.4 return (magic == 1886961915); 1.5 } 1.6 1.7 +static char buffer[512]; 1.8 + 1.9 #define MODE_READ 0 1.10 #define MODE_WRITE 1 1.11 -static int rdwrsector(int mode, int drive, unsigned long startingsector, 1.12 - unsigned long count, char *buffer) 1.13 +static int rdwrsector(int mode, int drive, unsigned long startingsector) 1.14 { 1.15 HANDLE hDevice; 1.16 DWORD result; 1.17 @@ -107,11 +108,11 @@ 1.18 return -1; 1.19 SetFilePointer(hDevice, (startingsector*512), NULL, FILE_BEGIN); 1.20 if (mode == MODE_READ) { 1.21 - if (!ReadFile(hDevice, buffer, 512*count, &result, NULL)) 1.22 + if (!ReadFile(hDevice, buffer, 512, &result, NULL)) 1.23 result = -1; 1.24 } 1.25 else { 1.26 - if (!WriteFile(hDevice, buffer, 512*count, &result, NULL)) 1.27 + if (!WriteFile(hDevice, buffer, 512, &result, NULL)) 1.28 result = -1; 1.29 } 1.30 CloseHandle(hDevice); 1.31 @@ -121,18 +122,15 @@ 1.32 static int rawrite(unsigned long drive, char *isoFileName) 1.33 { 1.34 int fdiso, s, dev; 1.35 - char buffer[2048]; 1.36 1.37 if (drive == 0) return; 1.38 for (dev = 128; (drive & 1) == 0; dev++) 1.39 drive >>= 1; 1.40 fdiso = open(isoFileName, O_RDONLY|O_BINARY); 1.41 - for (s = 0;;) { 1.42 + for (s = 0;; s++) { 1.43 int s, n = read(fdiso, buffer, sizeof(buffer)); 1.44 if (n <= 0) break; 1.45 - n = (n+511)/512; 1.46 - rdwrsector(MODE_WRITE, dev, s, n, buffer); 1.47 - s += n; 1.48 + rdwrsector(MODE_WRITE, dev, s); 1.49 } 1.50 close(fdiso); 1.51 return dev; 1.52 @@ -141,9 +139,9 @@ 1.53 static unsigned long drives(void) 1.54 { 1.55 int i, mask, result; 1.56 - char buffer[512]; 1.57 + 1.58 for (i = result = 0, mask = 1; i < 8; i++, mask <<= 1) { 1.59 - if (rdwrsector(MODE_READ, i+128, 0, 1, buffer) != -1) 1.60 + if (rdwrsector(MODE_READ, i+128, 0) != -1) 1.61 result |= mask; 1.62 } 1.63 return result; 1.64 @@ -151,7 +149,6 @@ 1.65 1.66 static void writefloppy(char *isoFileName) 1.67 { 1.68 - char buffer[512]; 1.69 int i, n, fd; 1.70 1.71 buffer[BOOTSTRAP_SECTOR_COUNT_OFFSET] = 0; 1.72 @@ -162,10 +159,10 @@ 1.73 if (n != 0 && 1.74 lseek(fd, * (unsigned short *) (buffer + 66) - (512 * n), 1.75 SEEK_SET) != -1) { 1.76 - for (i = 0; i < n; i++) { 1.77 - read(fd, buffer, 512); 1.78 + for (i = 0; i <= n; i++) { 1.79 if (i == 1) strncpy(buffer, isoFileName, 512); 1.80 - rdwrsector(MODE_WRITE, 0, i, 1, buffer); 1.81 + else read(fd, buffer, 512); 1.82 + rdwrsector(MODE_WRITE, 0, i); 1.83 } 1.84 } 1.85 close(fd);