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 "kern_util.h"
15 /* Changed by uml_initrd_setup, which is a setup */
16 static char *initrd __initdata
= NULL
;
18 static int __init
read_initrd(void)
27 err
= os_file_size(initrd
, &size
);
31 area
= alloc_bootmem(size
);
35 if(load_initrd(initrd
, area
, size
) == -1)
38 initrd_start
= (unsigned long) area
;
39 initrd_end
= initrd_start
+ size
;
43 __uml_postsetup(read_initrd
);
45 static int __init
uml_initrd_setup(char *line
, int *add
)
51 __uml_setup("initrd=", uml_initrd_setup
,
52 "initrd=<initrd image>\n"
53 " This is used to boot UML from an initrd image. The argument is the\n"
54 " name of the file containing the image.\n\n"
57 int load_initrd(char *filename
, void *buf
, int size
)
61 fd
= os_open_file(filename
, of_read(OPENFLAGS()), 0);
63 printk("Opening '%s' failed - err = %d\n", filename
, -fd
);
66 n
= os_read_file(fd
, buf
, size
);
68 printk("Read of %d bytes from '%s' failed, err = %d\n", size
,