Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > bd83eed6316a8b1c5c9b7e319c5581d0 > files > 10

mkinitrd-6.0.63-1mnb2.src.rpm

diff -p -up mkinitrd-6.0.52/nash/nash.c.checkroot mkinitrd-6.0.52/nash/nash.c
--- mkinitrd-6.0.52/nash/nash.c.checkroot	2008-07-23 21:51:08.000000000 +0200
+++ mkinitrd-6.0.52/nash/nash.c	2008-07-24 09:59:40.000000000 +0200
@@ -1215,6 +1215,7 @@ switchrootCommand(char * cmd, char * end
     const char *initprogs[] = { "/sbin/init", "/etc/init",
                                 "/bin/init", "/bin/sh", NULL };
     char *init, **initargs;
+    char *newdev;
     char *cmdline = NULL;
     char *new = NULL, *arg;
     int fd, i = 0;
@@ -1235,6 +1236,14 @@ switchrootCommand(char * cmd, char * end
     if (new == NULL)
         new = "/sysroot";
 
+    asprintf(&newdev, "%s/dev", new);
+    if (access(newdev, R_OK)) {
+        free(newdev);
+        eprintf("switchroot: /dev does not exist in new root\n");
+        return 1;
+    }
+    free(newdev);
+
     /* this has to happen before we unmount /proc */
     init = getKernelArg("init");
     if (init == NULL)