wok-next diff syslinux/stuff/iso2exe/boot.c @ rev 17489
syslinux/iso2exe: add knoppix support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jan 01 22:09:19 2015 +0100 (2015-01-01) |
parents | 8cf93f4aedd1 |
children | 2c2a6dd5ba40 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/boot.c Sun Mar 09 14:09:57 2014 +0000 1.2 +++ b/syslinux/stuff/iso2exe/boot.c Thu Jan 01 22:09:19 2015 +0100 1.3 @@ -10,10 +10,10 @@ 1.4 static void usage(char *iso) 1.5 { 1.6 printf("Usage: %s [[@commands]|[kernel=<bzimage>] \ 1.7 -[initrd=<rootfs>[,<rootfs2>...]] [iso=<isofile>] ...]\n\n\ 1.8 +[initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] ...]\n\n\ 1.9 Defaults: %s @tazboot.cmd or %s kernel=bzImage auto\n\n\ 1.10 Examples for tazboot.cmd:\n\n\ 1.11 - iso=\\isos\\slitaz-4.0.iso\n\ 1.12 + bootfrom=\\isos\\slitaz-4.0.iso\n\ 1.13 kernel=boot/bzImage\n\ 1.14 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz,\\slitaz\\extrafs.gz\n\ 1.15 rw root=/dev/null vga=normal autologin\n\n\ 1.16 @@ -25,30 +25,52 @@ 1.17 static void bootiso(char **iso) 1.18 { 1.19 char *init = " rdinit=/init.exe", *mode="menu", *fmt=""; 1.20 - char c, rootfs[16], cmdline[256]; 1.21 - int restart; 1.22 + char *s, c, rootfs[16], fallback[16], cmdline[256]; 1.23 + int restart, isknoppix = 0; 1.24 unsigned long magic; 1.25 1.26 - if (isoreset(*iso) || isoopen("boot")) return; 1.27 + if (isoreset(*iso)) return; 1.28 + !isoopen("boot") || 1.29 + !isoopen("live") || // debian 1.30 + !isoopen("casper") || // ubuntu 1.31 + !isoopen("isolinux"); // zeroshell 1.32 if (iso[1] && !strcmp(mode = iso[1], "text")) 1.33 init = ""; 1.34 + do { 1.35 + if (!isoopen(mode) || // custom 1.36 + !isoopen("bzImage") || // SliTaz 1.37 + !isoopen("linux24") || // dsl 1.38 + !isoopen("vmlinuz") || // misc 1.39 + (!isoopen("linux") && ++isknoppix)) { 1.40 + magic = loadkernel(); 1.41 + break; 1.42 + } 1.43 + } while (!isoopen("isolinux")); // Knoppix 1.44 + fallback[0] = 0; 1.45 for (c = 0, restart = 1; isoreaddir(restart) == 0; restart = 0) { 1.46 + if (strstr(isofilename, ".gz")) 1.47 + strcpy(fallback, isofilename); 1.48 if (strncmp(isofilename, "rootfs", 6) 1.49 || c > isofilename[6]) continue; 1.50 strcpy(rootfs, isofilename); 1.51 c = isofilename[6]; 1.52 } 1.53 - if (isoopen(mode)) 1.54 - isoopen("bzImage"); 1.55 - magic = loadkernel(); 1.56 + 1.57 if (magic < 0x20630) 1.58 init = ""; // Does not support multiple initramfs 1.59 + 1.60 if (magic > 0) { 1.61 - fmt = "rw root=/dev/null%s iso=%s magic=%lu mode=%s autologin"; 1.62 - if (rootfs[6] != '.' && !isoopen("rootfs.gz")) 1.63 - loadinitrd(); // for loram 1.64 - isoopen(rootfs); 1.65 - loadinitrd(); 1.66 + char *initrd = fallback; 1.67 + 1.68 + fmt = "rw root=/dev/null bootfrom=%s%s magic=%lu mode=%s autologin"; 1.69 + if (rootfs[0]) { 1.70 + initrd = rootfs; 1.71 + if (rootfs[6] != '.' && !isoopen("rootfs.gz")) 1.72 + loadinitrd(); // for loram 1.73 + } 1.74 + if (!isoopen(initrd)) { 1.75 + loadinitrd(); 1.76 + } 1.77 if (*init) { 1.78 lseek(isofd, 24L, SEEK_SET); 1.79 read(isofd, &magic, 4); 1.80 @@ -58,7 +80,13 @@ 1.81 else init=""; 1.82 } 1.83 } 1.84 - sprintf(cmdline, fmt, init, *iso, magic, mode); 1.85 + if (isknoppix) { 1.86 + if (iso[0][1] == ':') 1.87 + *iso += 2; 1.88 + for (s = *iso; *s; s++) 1.89 + if (*s == '\\') *s = '/'; 1.90 + } 1.91 + sprintf(cmdline, fmt, *iso, init, magic, mode); 1.92 close(isofd); 1.93 bootlinux(cmdline); 1.94 } 1.95 @@ -159,7 +187,7 @@ 1.96 kernel = s + 7; 1.97 else if (stricmp("initrd=", s) == 0) 1.98 initrd = s + 7; 1.99 - else if (stricmp("iso=", s) == 0) 1.100 + else if (stricmp("bootfrom=", s) == 0) 1.101 iso = s + 4; 1.102 else { 1.103 cmdline = s;