aboutsummaryrefslogtreecommitdiff
path: root/arch/um/kernel/initrd.c
diff options
context:
space:
mode:
authorGravatar Vincent Whitchurch <vincent.whitchurch@axis.com> 2021-12-08 16:11:22 +0100
committerGravatar Richard Weinberger <richard@nod.at> 2021-12-22 20:32:36 +0100
commit361640b4fdc86167b0c25d8e73c08dcaa4ecd28a (patch)
tree36af31f11c70be3c0e135c6c56a5bc569acef444 /arch/um/kernel/initrd.c
parentum: remove set_fs (diff)
downloadlinux-361640b4fdc86167b0c25d8e73c08dcaa4ecd28a.tar.gz
linux-361640b4fdc86167b0c25d8e73c08dcaa4ecd28a.tar.bz2
linux-361640b4fdc86167b0c25d8e73c08dcaa4ecd28a.zip
um: Extract load file helper from initrd.c
The file loading support in initrd.c can be re-used for loading devicetrees. Move it out of initrd.c. Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/kernel/initrd.c')
-rw-r--r--arch/um/kernel/initrd.c48
1 files changed, 5 insertions, 43 deletions
diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
index c1981ffb7179..47b8cb1a1156 100644
--- a/arch/um/kernel/initrd.c
+++ b/arch/um/kernel/initrd.c
@@ -10,37 +10,21 @@
#include <init.h>
#include <os.h>
+#include "um_arch.h"
+
/* Changed by uml_initrd_setup, which is a setup */
static char *initrd __initdata = NULL;
-static int load_initrd(char *filename, void *buf, int size);
int __init read_initrd(void)
{
+ unsigned long long size;
void *area;
- long long size;
- int err;
-
- if (initrd == NULL)
- return 0;
- err = os_file_size(initrd, &size);
- if (err)
+ if (!initrd)
return 0;
- /*
- * This is necessary because alloc_bootmem craps out if you
- * ask for no memory.
- */
- if (size == 0) {
- printk(KERN_ERR "\"%s\" is a zero-size initrd\n", initrd);
- return 0;
- }
-
- area = memblock_alloc(size, SMP_CACHE_BYTES);
+ area = uml_load_file(initrd, &size);
if (!area)
- panic("%s: Failed to allocate %llu bytes\n", __func__, size);
-
- if (load_initrd(initrd, area, size) == -1)
return 0;
initrd_start = (unsigned long) area;
@@ -59,25 +43,3 @@ __uml_setup("initrd=", uml_initrd_setup,
" This is used to boot UML from an initrd image. The argument is the\n"
" name of the file containing the image.\n\n"
);
-
-static int load_initrd(char *filename, void *buf, int size)
-{
- int fd, n;
-
- fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
- if (fd < 0) {
- printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename,
- -fd);
- return -1;
- }
- n = os_read_file(fd, buf, size);
- if (n != size) {
- printk(KERN_ERR "Read of %d bytes from '%s' failed, "
- "err = %d\n", size,
- filename, -n);
- return -1;
- }
-
- os_close_file(fd);
- return 0;
-}