wok diff syslinux/stuff/iso2exe/iso2exe.c @ rev 18909
Add gnubg
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Feb 22 21:29:18 2016 +0100 (2016-02-22) |
parents | f937073af512 |
children | 56825fa17de8 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Sun Feb 14 22:06:06 2016 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Mon Feb 22 21:29:18 2016 +0100 1.3 @@ -63,7 +63,7 @@ 1.4 static uint64_t total64; /* must be directly before hash[] */ 1.5 static uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */ 1.6 1.7 -//#define rotl32(x,n) (((x) << (n)) | ((x) >> (32 - (n)))) 1.8 +/* #define rotl32(x,n) (((x) << (n)) | ((x) >> (32 - (n)))) */ 1.9 static uint32_t rotl32(uint32_t x, unsigned n) 1.10 { 1.11 return (x << n) | (x >> (32 - n)); 1.12 @@ -114,10 +114,10 @@ 1.13 /* Do we have enough space for the length count? */ 1.14 if (remaining >= 8) { 1.15 /* Store the 64-bit counter of bits in the buffer */ 1.16 - //uint64_t t = total64 << 3; 1.17 + /* uint64_t t = total64 << 3; */ 1.18 uint32_t *t = (uint32_t *) (&wbuffer[64 - 8]); 1.19 /* wbuffer is suitably aligned for this */ 1.20 - //*(uint64_t *) (&wbuffer[64 - 8]) = t; 1.21 + /* *(uint64_t *) (&wbuffer[64 - 8]) = t; */ 1.22 t[0] = total64.l << 3; 1.23 t[1] = (total64.h << 3) | (total64.l >> 29); 1.24 } 1.25 @@ -287,14 +287,6 @@ 1.26 unsigned long size, catalog, lba; 1.27 int cylinders, i, j, isohybrid; 1.28 unsigned n; 1.29 -#ifdef __MSDOS__ 1.30 - for (bootiso = (char *) install; 1.31 - bootiso[0] != 'M' || bootiso[1] != 'Z' || bootiso[2] != '\xEB'; 1.32 - bootiso++) if (bootiso < (char *) install) { 1.33 - bootiso = "No bootiso data"; 1.34 - return 0; 1.35 - } 1.36 -#endif 1.37 if (!filename) 1.38 return USAGE; 1.39 fd = open(filename,O_RDWR|O_BINARY); 1.40 @@ -314,8 +306,7 @@ 1.41 for (i = 0; i < 32; i++, n = BUFFERSZ) { 1.42 write(fd, buffer + n, BUFFERSZ); 1.43 } 1.44 - i = getcustomsector(); 1.45 - lseek(fd, i * 2048UL, SEEK_SET); 1.46 + lseek(fd, getcustomsector() << 11, SEEK_SET); 1.47 i = clear_config(i); 1.48 ftruncate(fd, i * 2048UL); 1.49 close(fd); 1.50 @@ -393,12 +384,12 @@ 1.51 lseek(fd, pos, SEEK_SET); 1.52 clear_config(pos); 1.53 lseek(fd, pos, SEEK_SET); 1.54 - write(fd, "#!boot 00000000000000000000000000000000\n", 40); 1.55 + write(fd, bootiso+CUSTOM_HEADER, 40); 1.56 n = pos + 40; 1.57 md5_begin(); 1.58 if (append) { 1.59 i = strlen(append); 1.60 - writenhash("append=", 7); 1.61 + writenhash(bootiso+CMDLINE_TAG, 7); 1.62 writenhash(append, i); 1.63 writenhash("\n", 1); 1.64 n += i + 8; 1.65 @@ -421,7 +412,7 @@ 1.66 x /= 10; 1.67 } while (x); 1.68 if (*++p != '0') { 1.69 - writenhash("initrd:", 7); 1.70 + writenhash(bootiso+INITRD_TAG, 7); 1.71 i = number - p + sizeof(number); 1.72 writenhash(p, i); 1.73 n += i + 7; 1.74 @@ -494,7 +485,7 @@ 1.75 return SUCCESSMSG; 1.76 } 1.77 1.78 -static unsigned short files[] = { // to move to iso2exe.sh .... 1.79 +static unsigned short files[] = { 1.80 WIN32_EXE, /* 0 */ 1.81 SYSLINUX_MBR, /* 1 */ 1.82 FLAVOR_INFO, /* 2 */ 1.83 @@ -516,7 +507,7 @@ 1.84 char *s; 1.85 1.86 c = getcustomsector(); 1.87 - readsector(0); 1.88 + readsector(0UL); 1.89 i = 1024; 1.90 if (WORD(buffer+1024) != 35615) i = 512 * (1 + BYTE(buffer+417)); 1.91 stub = WORD(buffer+20) - 0xC0; 1.92 @@ -547,7 +538,7 @@ 1.93 file_offset = 0x8000U; file_size = 2048*c - file_offset; break; 1.94 case CUSTOM_MAGIC: /* custom.magic */ 1.95 readsector(c); 1.96 - if (!strncmp(buffer, "#!boot", 6)) { 1.97 + if (!strncmp(buffer, bootiso+CUSTOM_HEADER, 6)) { 1.98 file_size = 39; file_offset = 2048*c; 1.99 }; break; 1.100 case CUSTOM_APPEND: /* custom.append */ 1.101 @@ -565,26 +556,34 @@ 1.102 } 1.103 } 1.104 1.105 +static long heap = 0; 1.106 +static void show_free(void) 1.107 +{ 1.108 + if (file_offset > heap && (file_offset - heap) > 16) 1.109 + printf(bootiso + FREE_FORMAT, file_offset - heap, 1.110 + heap, file_offset); 1.111 +} 1.112 + 1.113 static void list(void) 1.114 { 1.115 - int num, heap = 0; 1.116 + int num; 1.117 1.118 for (num = 0; num < sizeof(files)/sizeof(files[0]); num++) { 1.119 fileofs(num); 1.120 if (file_size <= 0 || file_offset > 0x3FFFFFFFUL) continue; 1.121 readsector(file_offset / 2048); 1.122 if (WORD(buffer + file_offset % 2048) == 0) continue; 1.123 - if (file_offset > heap && (file_offset - heap) > 16) 1.124 - printf("%d free bytes in %04X..%04X\n", 1.125 - file_offset - heap, heap, file_offset); 1.126 + show_free(); 1.127 if (file_offset >= heap) heap = file_offset + file_size; 1.128 - printf("%s at %04X (%d bytes).\n", bootiso + files[num], 1.129 - file_offset, file_size); 1.130 + printf(bootiso + USED_FORMAT, bootiso + files[num], 1.131 + file_offset, file_size); 1.132 } 1.133 - file_offset=lseek(fd, 0UL, SEEK_END); 1.134 - if (file_offset > heap) 1.135 - printf("%d free bytes in %04X..%04X\n", 1.136 - file_offset - heap, heap, file_offset); 1.137 +#ifdef __MSDOS__ 1.138 + file_offset = (heap + 0xFFFFFUL) & 0xFFF00000UL; 1.139 +#else 1.140 + file_offset=lseek(fd, 0UL, SEEK_END); 1.141 +#endif 1.142 + show_free(); 1.143 } 1.144 1.145 static void extract(char *name) 1.146 @@ -612,6 +611,7 @@ 1.147 int i; 1.148 char *s; 1.149 1.150 + data_fixup(); 1.151 for (i = 0; argc > 2;) { 1.152 s = argv[1]; 1.153 if (*s != '-') break;