On Fri, 2006-02-24 at 10:54 -0600, Kumar Gala wrote:
> + if (strstr(cmd_line, "mem=")) {
> + char *p, *q;
> + unsigned long maxmem = 0;
> +
> + for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
> + q = p + 4;
> + if (p > cmd_line && p[-1] != ' ')
> + continue;
> + maxmem = simple_strtoul(q, &q, 0);
> + if (*q == 'k' || *q == 'K') {
> + maxmem <<= 10;
> + ++q;
> + } else if (*q == 'm' || *q == 'M') {
> + maxmem <<= 20;
> + ++q;
> + } else if (*q == 'g' || *q == 'G') {
> + maxmem <<= 30;
> + ++q;
> + }
> + }
> + memory_limit = maxmem;
> + }
You may want to check out lib/cmdline.c's memparse() function. I think
it does this for you.
-- Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]