From a7e3d0520856db27744b4a33e786123d44bf5b2a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 21 Feb 2006 06:11:13 +0000 Subject: Create /dev/root symlink pointing to real root device, if any. --- util-linux/mdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util-linux') diff --git a/util-linux/mdev.c b/util-linux/mdev.c index f6d4d8df0..5fea1b8e2 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,8 @@ #include +int root_major, root_minor; + /* mknod in /dev based on a path like "/sys/block/hda/hda1" */ static void make_device(char *path) { @@ -169,6 +172,9 @@ found_device: if (mknod(temp, mode | type, makedev(major, minor)) && errno != EEXIST) bb_perror_msg_and_die("mknod %s failed", temp); + if (major==root_major && minor==root_minor) + symlink(temp,DEV_PATH "/root"); + if (ENABLE_FEATURE_MDEV_CONF) chown(temp,uid,gid); end: @@ -217,6 +223,11 @@ int mdev_main(int argc, char *argv[]) /* Scan */ if (argc == 2 && !strcmp(argv[1],"-s")) { + struct stat st; + + stat("/", &st); // If this fails, we have bigger problems. + root_major=major(st.st_dev); + root_minor=minor(st.st_dev); strcpy(temp,"/sys/block"); find_dev(temp); strcpy(temp,"/sys/class"); -- cgit v1.2.3