wok diff syslinux/stuff/iso2exe/iso2exe.c @ rev 17161
syslinux/iso2exe: full zImage support (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Sep 17 15:21:35 2014 +0200 (2014-09-17) |
parents | 19258b949c1b |
children | aca562aa836e |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Thu Apr 04 11:19:19 2013 +0200 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Wed Sep 17 15:21:35 2014 +0200 1.3 @@ -6,7 +6,7 @@ 1.4 #endif 1.5 #include "iso2exe.h" 1.6 1.7 -static int fd, status = 1; 1.8 +static int fd, forced, status = 1; 1.9 static char tazlitoinfo[10*1024]; 1.10 #define buffer tazlitoinfo 1.11 #define BUFFERSZ 2048 1.12 @@ -36,40 +36,43 @@ 1.13 bootiso++) if (bootiso < (char *) install) return "No bootiso data.\n"; 1.14 #endif 1.15 if (!filename) 1.16 - return "Usage: isohybrid.exe file.iso\n"; 1.17 + return "Usage: isohybrid.exe file.iso [--forced]\n"; 1.18 fd = open(filename,O_RDWR|O_BINARY); 1.19 if (fd == -1) 1.20 return "Can't open rw the iso file.\n"; 1.21 1.22 - // Install hybridiso boot sector 1.23 - readsector(17UL); 1.24 - if (strncmp(buffer+7, "EL TORITO SPECIFICATION", 23)) 1.25 - return "No EL TORITO signature.\n"; 1.26 - catalog = * (unsigned long *) (buffer + 71); 1.27 - readsector(catalog); 1.28 - if (* (unsigned long *) buffer != 1 || 1.29 - * (unsigned long *) (buffer + 30) != 0x88AA55) 1.30 - return "Invalid boot catalog.\n"; 1.31 - lba = * (unsigned long *) (buffer + 40); 1.32 - readsector(lba); 1.33 - if (* (unsigned long *) (buffer + 64) != 1886961915) 1.34 - return "No isolinux.bin hybrid signature.\n"; 1.35 - isohybrid = bootiso[69] * 512; 1.36 - * (unsigned long *) &bootiso[isohybrid + 432] = lba * 4; 1.37 - * (unsigned long *) &bootiso[isohybrid + 440] = rand(); 1.38 - * (unsigned long *) &bootiso[isohybrid + partition] = 0x10080; 1.39 - * (unsigned short *) &bootiso[isohybrid + 510] = 0xAA55; 1.40 - size = lseek(fd, 0UL, SEEK_END); 1.41 - cylinders = (size + trksz - 1) / trksz; 1.42 - bootiso[isohybrid + partition + 4] = 23; // "Windows hidden IFS" 1.43 - bootiso[isohybrid + partition + 5] = heads - 1; 1.44 - bootiso[isohybrid + partition + 6] = (((cylinders - 1) & 0x300) >> 2) + sectors; 1.45 - bootiso[isohybrid + partition + 7] = (cylinders - 1) & 0xFF; 1.46 - * (unsigned long *) &bootiso[isohybrid + partition + 8] = 0; 1.47 - * (unsigned long *) &bootiso[isohybrid + partition + 12] = cylinders * sectors * heads; 1.48 + if (forced == 0) { 1.49 + status = 2; 1.50 + // Install hybridiso boot sector 1.51 + readsector(17UL); 1.52 + if (strncmp(buffer+7, "EL TORITO SPECIFICATION", 23)) 1.53 + return "No EL TORITO signature.\n"; 1.54 + catalog = * (unsigned long *) (buffer + 71); 1.55 + readsector(catalog); 1.56 + if (* (unsigned long *) buffer != 1 || 1.57 + * (unsigned long *) (buffer + 30) != 0x88AA55) 1.58 + return "Invalid boot catalog.\n"; 1.59 + lba = * (unsigned long *) (buffer + 40); 1.60 + readsector(lba); 1.61 + if (* (unsigned long *) (buffer + 64) != 1886961915) 1.62 + return "No isolinux.bin hybrid signature.\n"; 1.63 + isohybrid = bootiso[69] * 512; 1.64 + * (unsigned long *) &bootiso[isohybrid + 432] = lba * 4; 1.65 + * (unsigned long *) &bootiso[isohybrid + 440] = rand(); 1.66 + * (unsigned long *) &bootiso[isohybrid + partition] = 0x10080; 1.67 + * (unsigned short *) &bootiso[isohybrid + 510] = 0xAA55; 1.68 + size = lseek(fd, 0UL, SEEK_END); 1.69 + cylinders = (size + trksz - 1) / trksz; 1.70 + bootiso[isohybrid + partition + 4] = 23; // "Windows hidden IFS" 1.71 + bootiso[isohybrid + partition + 5] = heads - 1; 1.72 + bootiso[isohybrid + partition + 6] = (((cylinders - 1) & 0x300) >> 2) + sectors; 1.73 + bootiso[isohybrid + partition + 7] = (cylinders - 1) & 0xFF; 1.74 + * (unsigned long *) &bootiso[isohybrid + partition + 8] = 0; 1.75 + * (unsigned long *) &bootiso[isohybrid + partition + 12] = cylinders * sectors * heads; 1.76 1.77 - // Copy the partition table 1.78 - memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66); 1.79 + // Copy the partition table 1.80 + memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66); 1.81 + } 1.82 1.83 // Install iso2exe boot sector 1.84 * (unsigned short *) (bootiso + 26) = rand(); 1.85 @@ -106,7 +109,10 @@ 1.86 1.87 int main(int argc, char *argv[]) 1.88 { 1.89 + forced = (argc > 2); 1.90 puts(install(argv[1])); 1.91 + if (status > 1) 1.92 + puts("You can add --forced to proceed anayway"); 1.93 #ifdef WIN32 1.94 Sleep(2000); 1.95 #endif