wok-next rev 3867

syslinux/ifmem: add extra arguments in cmdline
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 08 16:04:33 2009 +0200 (2009-08-08)
parents 4076c5e6d6d9
children b6b64851e9aa
files syslinux/stuff/extra/ifmem.c
line diff
     1.1 --- a/syslinux/stuff/extra/ifmem.c	Sat Aug 08 10:22:34 2009 +0200
     1.2 +++ b/syslinux/stuff/extra/ifmem.c	Sat Aug 08 16:04:33 2009 +0200
     1.3 @@ -39,7 +39,7 @@
     1.4  #include <stdlib.h>
     1.5  #include <syslinux/boot.h>
     1.6  
     1.7 -static long memory_size(void)
     1.8 +static unsigned long memory_size(void)
     1.9  {
    1.10    com32sys_t ireg, oreg;
    1.11  
    1.12 @@ -64,14 +64,32 @@
    1.13      return 1;
    1.14    }
    1.15  
    1.16 +  # find target according to ram size
    1.17    for (i = 1; i + 2 < argc; ) { 
    1.18      i++; // size
    1.19      if (memory_size() >= strtoul(s, NULL, 0)) break;
    1.20      s = argv[++i];
    1.21    }
    1.22 -  if (argv[i])
    1.23 -    syslinux_run_command(argv[i]);
    1.24 -  else
    1.25 -    syslinux_run_default();
    1.26 +
    1.27 +  # find and copy extra parameters to command line
    1.28 +  # assume last parameter is "noram"
    1.29 +  for (s = argv[i]; i < argc; i++) { 
    1.30 +	if (!strcmp(argv[i],"noram") && ++i < argc) {
    1.31 +#define SZ 512
    1.32 +		static char cmdline[SZ];
    1.33 +		char *p = cmdline, *q = s;
    1.34 +		int j;
    1.35 +		for (j = i; j <= argc; j++) {
    1.36 +			while (*q && p < cmdline + SZ -1) *p++ = *q++;
    1.37 +			if (p < cmdline + SZ -1) *p++ = ' ';
    1.38 +			q = argv[j];
    1.39 +		}
    1.40 +		*p++ = 0;
    1.41 +		s = cmdline;
    1.42 +	}
    1.43 +  }
    1.44 +
    1.45 +  if (s) syslinux_run_command(s);
    1.46 +  else   syslinux_run_default();
    1.47    return -1;
    1.48  }