aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/linux.c274
1 files changed, 137 insertions, 137 deletions
diff --git a/com32/modules/linux.c b/com32/modules/linux.c
index 0c40df2d..b902ebc5 100644
--- a/com32/modules/linux.c
+++ b/com32/modules/linux.c
@@ -53,164 +53,164 @@ const char *progname = "linux.c32";
(which should include the final =; do not use for boolean arguments) */
static char *find_argument(char **argv, const char *argument)
{
- int la = strlen(argument);
- char **arg;
- char *ptr = NULL;
+ int la = strlen(argument);
+ char **arg;
+ char *ptr = NULL;
- for (arg = argv; *arg; arg++) {
- if (!memcmp(*arg, argument, la))
- ptr = *arg + la;
- }
+ for (arg = argv; *arg; arg++) {
+ if (!memcmp(*arg, argument, la))
+ ptr = *arg + la;
+ }
- return ptr;
+ return ptr;
}
/* Search for a boolean argument; return its position, or 0 if not present */
static int find_boolean(char **argv, const char *argument)
{
- char **arg;
-
- for (arg = argv; *arg; arg++) {
- if (!strcmp(*arg, argument))
- return (arg-argv)+1;
- }
-
- return 0;
+ char **arg;
+
+ for (arg = argv; *arg; arg++) {
+ if (!strcmp(*arg, argument))
+ return (arg - argv) + 1;
+ }
+
+ return 0;
}
/* Stitch together the command line from a set of argv's */
static char *make_cmdline(char **argv)
{
- char **arg;
- size_t bytes;
- char *cmdline, *p;
-
- bytes = 1; /* Just in case we have a zero-entry cmdline */
- for (arg = argv; *arg; arg++) {
- bytes += strlen(*arg)+1;
- }
-
- p = cmdline = malloc(bytes);
- if (!cmdline)
- return NULL;
-
- for (arg = argv; *arg; arg++) {
- int len = strlen(*arg);
- memcpy(p, *arg, len);
- p[len] = ' ';
- p += len+1;
- }
-
- if (p > cmdline)
- p--; /* Remove the last space */
- *p = '\0';
-
- return cmdline;
+ char **arg;
+ size_t bytes;
+ char *cmdline, *p;
+
+ bytes = 1; /* Just in case we have a zero-entry cmdline */
+ for (arg = argv; *arg; arg++) {
+ bytes += strlen(*arg) + 1;
+ }
+
+ p = cmdline = malloc(bytes);
+ if (!cmdline)
+ return NULL;
+
+ for (arg = argv; *arg; arg++) {
+ int len = strlen(*arg);
+ memcpy(p, *arg, len);
+ p[len] = ' ';
+ p += len + 1;
+ }
+
+ if (p > cmdline)
+ p--; /* Remove the last space */
+ *p = '\0';
+
+ return cmdline;
}
int main(int argc, char *argv[])
{
- const char *kernel_name;
- struct initramfs *initramfs;
- char *cmdline;
- char *boot_image;
- void *kernel_data;
- size_t kernel_len;
- bool opt_dhcpinfo = false;
- bool opt_quiet = false;
- void *dhcpdata;
- size_t dhcplen;
- char **argp, *arg, *p;
-
- openconsole(&dev_null_r, &dev_stdcon_w);
-
- (void)argc;
- argp = argv+1;
-
- while ((arg = *argp) && arg[0] == '-') {
- if (!strcmp("-dhcpinfo", arg)) {
- opt_dhcpinfo = true;
- } else {
- fprintf(stderr, "%s: unknown option: %s\n", progname, arg);
- return 1;
+ const char *kernel_name;
+ struct initramfs *initramfs;
+ char *cmdline;
+ char *boot_image;
+ void *kernel_data;
+ size_t kernel_len;
+ bool opt_dhcpinfo = false;
+ bool opt_quiet = false;
+ void *dhcpdata;
+ size_t dhcplen;
+ char **argp, *arg, *p;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ (void)argc;
+ argp = argv + 1;
+
+ while ((arg = *argp) && arg[0] == '-') {
+ if (!strcmp("-dhcpinfo", arg)) {
+ opt_dhcpinfo = true;
+ } else {
+ fprintf(stderr, "%s: unknown option: %s\n", progname, arg);
+ return 1;
+ }
+ argp++;
}
- argp++;
- }
- if (!arg) {
- fprintf(stderr, "%s: missing kernel name\n", progname);
- return 1;
- }
-
- kernel_name = arg;
-
- boot_image = malloc(strlen(kernel_name)+12);
- if (!boot_image)
- goto bail;
- strcpy(boot_image, "BOOT_IMAGE=");
- strcpy(boot_image+11, kernel_name);
- /* argp now points to the kernel name, and the command line follows.
- Overwrite the kernel name with the BOOT_IMAGE= argument, and thus
- we have the final argument. */
- *argp = boot_image;
-
- if (find_boolean(argp,"quiet"))
- opt_quiet = true;
-
- if (!opt_quiet)
- printf("Loading %s... ", kernel_name);
- if (loadfile(kernel_name, &kernel_data, &kernel_len)) {
- if (opt_quiet)
- printf("Loading %s ", kernel_name);
- printf("failed!\n");
- goto bail;
- }
- if (!opt_quiet)
- printf("ok\n");
-
- cmdline = make_cmdline(argp);
- if (!cmdline)
- goto bail;
-
- /* Initialize the initramfs chain */
- initramfs = initramfs_init();
- if (!initramfs)
- goto bail;
-
- if ((arg = find_argument(argp, "initrd="))) {
- do {
- p = strchr(arg, ',');
- if (p)
- *p = '\0';
-
- if (!opt_quiet)
- printf("Loading %s... ", arg);
- if (initramfs_load_archive(initramfs, arg)) {
+ if (!arg) {
+ fprintf(stderr, "%s: missing kernel name\n", progname);
+ return 1;
+ }
+
+ kernel_name = arg;
+
+ boot_image = malloc(strlen(kernel_name) + 12);
+ if (!boot_image)
+ goto bail;
+ strcpy(boot_image, "BOOT_IMAGE=");
+ strcpy(boot_image + 11, kernel_name);
+ /* argp now points to the kernel name, and the command line follows.
+ Overwrite the kernel name with the BOOT_IMAGE= argument, and thus
+ we have the final argument. */
+ *argp = boot_image;
+
+ if (find_boolean(argp, "quiet"))
+ opt_quiet = true;
+
+ if (!opt_quiet)
+ printf("Loading %s... ", kernel_name);
+ if (loadfile(kernel_name, &kernel_data, &kernel_len)) {
if (opt_quiet)
- printf("Loading %s ", kernel_name);
+ printf("Loading %s ", kernel_name);
printf("failed!\n");
goto bail;
- }
- if (!opt_quiet)
+ }
+ if (!opt_quiet)
printf("ok\n");
- if (p)
- *p++ = ',';
- } while ((arg = p));
- }
-
- /* Append the DHCP info */
- if (opt_dhcpinfo &&
- !pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
- if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen,
- "/dhcpinfo.dat", 0, 0755))
- goto bail;
- }
-
- /* This should not return... */
- syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline);
-
- bail:
- fprintf(stderr, "Kernel load failure (insufficient memory?)\n");
- return 1;
+ cmdline = make_cmdline(argp);
+ if (!cmdline)
+ goto bail;
+
+ /* Initialize the initramfs chain */
+ initramfs = initramfs_init();
+ if (!initramfs)
+ goto bail;
+
+ if ((arg = find_argument(argp, "initrd="))) {
+ do {
+ p = strchr(arg, ',');
+ if (p)
+ *p = '\0';
+
+ if (!opt_quiet)
+ printf("Loading %s... ", arg);
+ if (initramfs_load_archive(initramfs, arg)) {
+ if (opt_quiet)
+ printf("Loading %s ", kernel_name);
+ printf("failed!\n");
+ goto bail;
+ }
+ if (!opt_quiet)
+ printf("ok\n");
+
+ if (p)
+ *p++ = ',';
+ } while ((arg = p));
+ }
+
+ /* Append the DHCP info */
+ if (opt_dhcpinfo &&
+ !pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) {
+ if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen,
+ "/dhcpinfo.dat", 0, 0755))
+ goto bail;
+ }
+
+ /* This should not return... */
+ syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline);
+
+bail:
+ fprintf(stderr, "Kernel load failure (insufficient memory?)\n");
+ return 1;
}