Skip to contentSkip to conversation

Don't remove /sys in initramfs

PATCH Superseded Juerg Billeter 1 participant 1 message Oct 28, 2004 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't remove /sys in initramfs

Hi

Using the "resume" kernel parameter together with an initramfs revealed a bug that causes removal of the /sys directory in the initramfs' tmpfs, making the system unbootable.

The source of the problem is that the try_name() function removes the /sys directory unconditionally, instead of removing it only when it has been created by try_name().

The attached patch only removes /sys if it has been created before.

Please CC me, I'm not on lkml.

Juerg

--

init/do_mounts.c 2004-10-28 19:04:10.803026647 +0200 renamed from init/do_mounts.c 2004-10-18 23:53:51.000000000 +0200 +3 -2
diff -uNr linux-2.6.9.orig/init/do_mounts.c linux-2.6.9/init/do_mounts.c
@@ -142,7 +142,7 @@
        int part;
 
 #ifdef CONFIG_SYSFS
-       sys_mkdir("/sys", 0700);
+       int mkdir_err = sys_mkdir("/sys", 0700);
        if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
                goto out;
 #endif
@@ -197,7 +197,8 @@
 #ifdef CONFIG_SYSFS
        sys_umount("/sys", 0);
 out:
-       sys_rmdir("/sys");
+       if (!mkdir_err)
+               sys_rmdir("/sys");
 #endif
        return res;
 fail: