NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-i386/41932: bootloader should explicitly warn failure of loading modules



>Number:         41932
>Category:       port-i386
>Synopsis:       bootloader should explicitly warn failure of loading modules
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 24 14:00:07 +0000 2009
>Originator:     Izumi Tsutsui
>Release:        NetBSD 5.99.15
>Organization:
>Environment:
System: NetBSD/i386
Architecture: i386
Machine: i386
>Description:
The x86 bootloader loads a module for root filesystem automatically,
and failure of loading a module cause an error "can't mount root" later.

The loader put a warning message of the failure, but
it will be cleared as soon as a loaded kernel is started and
it's difficult to see what's the actual problem for some users.

>How-To-Repeat:
Boot a newer revision kernel without extracted modules in /stand.

>Fix:

The following diff adds 5s delay after warning messages
before starting kernel.

Index: i386/stand/lib/exec.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/exec.c,v
retrieving revision 1.40
diff -u -r1.40 exec.c
--- i386/stand/lib/exec.c       21 Mar 2009 15:01:56 -0000      1.40
+++ i386/stand/lib/exec.c       24 Aug 2009 13:50:48 -0000
@@ -388,7 +388,9 @@
        boot_module_t *bm;
        size_t len;
        off_t off;
-       int err, fd;
+       int err, fd, warned;
+
+       warned = 0;
 
        switch (netbsd_elf_class) {
        case ELFCLASS32:
@@ -422,6 +424,7 @@
                fd = module_open(bm, 0);
                if (fd == -1) {
                        bm->bm_len = -1;
+                       warned = 1;
                        continue;
                }
                err = fstat(fd, &st);
@@ -429,6 +432,7 @@
                        printf("WARNING: couldn't stat %s\n", bm->bm_path);
                        close(fd);
                        bm->bm_len = -1;
+                       warned = 1;
                        continue;
                }
                bm->bm_len = st.st_size;
@@ -440,7 +444,8 @@
        btinfo_modulelist = alloc(len);
        if (btinfo_modulelist == NULL) {
                printf("WARNING: couldn't allocate module list\n");
-               return;
+               warned = 1;
+               goto out;
        }
        memset(btinfo_modulelist, 0, len);
        btinfo_modulelist_size = len;
@@ -458,6 +463,7 @@
                fd = module_open(bm, 0);
                if (fd == -1) {
                        printf("ERROR: couldn't open %s\n", bm->bm_path);
+                       warned = 1;
                        continue;
                }
                image_end = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
@@ -466,6 +472,7 @@
                        if ((howto & AB_SILENT) != 0)
                                printf("Loading %s ", bm->bm_path);
                        printf(" FAILED\n");
+                       warned = 1;
                } else {
                        btinfo_modulelist->num++;
                        bi = (struct bi_modulelist_entry *)(buf + off);
@@ -482,6 +489,11 @@
                close(fd);
        }
        btinfo_modulelist->endpa = image_end;
+
+ out:
+       if (warned != 0)
+               /* give a chance for users to read warning messages */
+               delay(5 * 1000 * 1000);
 }
 
 int



Home | Main Index | Thread Index | Old Index