aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel/initrd.c
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2008-02-05 01:31:08 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:29 -0500
commit0983a88b9f0ceffb2116ce92c7b273ce2aec7b93 (patch)
treecf63f0646f64eecc80e5e3cd8d9c16252a751d8e /arch/um/kernel/initrd.c
parent8efa3c9d545ab6adc5c5e001cbd7aee60909b3da (diff)
uml: install panic notifier earlier
It turns out that if there's a panic early enough, UML will just sit there in the LED-blinking loop because the panic notifier hadn't been installed yet. This patch installs it earlier. It also fixes the problem which exposed the hang, namely that if you give UML a zero-sized initrd, it will ask alloc_bootmem for zero bytes, and that will cause the panic. While I was in initrd.c, I gave it a style makeover. Prompted by checkpatch, I moved a couple extern declarations of uml_exitcode to kern_util.h. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/kernel/initrd.c')
-rw-r--r--arch/um/kernel/initrd.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/arch/um/kernel/initrd.c b/arch/um/kernel/initrd.c
index ae31c62f032..fa015565001 100644
--- a/arch/um/kernel/initrd.c
+++ b/arch/um/kernel/initrd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
@@ -20,18 +20,27 @@ static int __init read_initrd(void)
20 long long size; 20 long long size;
21 int err; 21 int err;
22 22
23 if(initrd == NULL) 23 if (initrd == NULL)
24 return 0; 24 return 0;
25 25
26 err = os_file_size(initrd, &size); 26 err = os_file_size(initrd, &size);
27 if(err) 27 if (err)
28 return 0; 28 return 0;
29 29
30 /*
31 * This is necessary because alloc_bootmem craps out if you
32 * ask for no memory.
33 */
34 if (size == 0) {
35 printk(KERN_ERR "\"%\" is a zero-size initrd\n");
36 return 0;
37 }
38
30 area = alloc_bootmem(size); 39 area = alloc_bootmem(size);
31 if(area == NULL) 40 if (area == NULL)
32 return 0; 41 return 0;
33 42
34 if(load_initrd(initrd, area, size) == -1) 43 if (load_initrd(initrd, area, size) == -1)
35 return 0; 44 return 0;
36 45
37 initrd_start = (unsigned long) area; 46 initrd_start = (unsigned long) area;
@@ -58,13 +67,15 @@ int load_initrd(char *filename, void *buf, int size)
58 int fd, n; 67 int fd, n;
59 68
60 fd = os_open_file(filename, of_read(OPENFLAGS()), 0); 69 fd = os_open_file(filename, of_read(OPENFLAGS()), 0);
61 if(fd < 0){ 70 if (fd < 0) {
62 printk("Opening '%s' failed - err = %d\n", filename, -fd); 71 printk(KERN_ERR "Opening '%s' failed - err = %d\n", filename,
72 -fd);
63 return -1; 73 return -1;
64 } 74 }
65 n = os_read_file(fd, buf, size); 75 n = os_read_file(fd, buf, size);
66 if(n != size){ 76 if (n != size) {
67 printk("Read of %d bytes from '%s' failed, err = %d\n", size, 77 printk(KERN_ERR "Read of %d bytes from '%s' failed, "
78 "err = %d\n", size,
68 filename, -n); 79 filename, -n);
69 return -1; 80 return -1;
70 } 81 }