2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/init.h"
7 #include "linux/bootmem.h"
8 #include "linux/initrd.h"
10 #include "user_util.h"
11 #include "kern_util.h"
16 /* Changed by uml_initrd_setup, which is a setup */
17 static char *initrd __initdata = NULL;
19 static int __init read_initrd(void)
25 if(initrd == NULL) return 0;
26 err = os_file_size(initrd, &size);
28 area = alloc_bootmem(size);
29 if(area == NULL) return 0;
30 if(load_initrd(initrd, area, size) == -1) return 0;
31 initrd_start = (unsigned long) area;
32 initrd_end = initrd_start + size;
36 __uml_postsetup(read_initrd);
38 static int __init uml_initrd_setup(char *line, int *add)
44 __uml_setup("initrd=", uml_initrd_setup,
45 "initrd=<initrd image>\n"
46 " This is used to boot UML from an initrd image. The argument is the\n"
47 " name of the file containing the image.\n\n"
50 int load_initrd(char *filename, void *buf, int size)
54 fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
56 printk("Opening '%s' failed - err = %d\n", filename, -fd);
59 n = os_read_file(fd, buf, size);
61 printk("Read of %d bytes from '%s' failed, err = %d\n", size,
70 * Overrides for Emacs so that we follow Linus's tabbing style.
71 * Emacs will notice this stuff at the end of the file and automatically
72 * adjust the settings for this buffer only. This must remain at the end
74 * ---------------------------------------------------------------------------
76 * c-file-style: "linux"