aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/mdev.c11
1 files changed, 11 insertions, 0 deletions
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 @@
16#include <string.h> 16#include <string.h>
17#include <sys/mman.h> 17#include <sys/mman.h>
18#include <sys/stat.h> 18#include <sys/stat.h>
19#include <sys/sysmacros.h>
19#include <sys/types.h> 20#include <sys/types.h>
20#include <unistd.h> 21#include <unistd.h>
21#include <stdlib.h> 22#include <stdlib.h>
@@ -27,6 +28,8 @@
27 28
28#include <busybox.h> 29#include <busybox.h>
29 30
31int root_major, root_minor;
32
30/* mknod in /dev based on a path like "/sys/block/hda/hda1" */ 33/* mknod in /dev based on a path like "/sys/block/hda/hda1" */
31static void make_device(char *path) 34static void make_device(char *path)
32{ 35{
@@ -169,6 +172,9 @@ found_device:
169 if (mknod(temp, mode | type, makedev(major, minor)) && errno != EEXIST) 172 if (mknod(temp, mode | type, makedev(major, minor)) && errno != EEXIST)
170 bb_perror_msg_and_die("mknod %s failed", temp); 173 bb_perror_msg_and_die("mknod %s failed", temp);
171 174
175 if (major==root_major && minor==root_minor)
176 symlink(temp,DEV_PATH "/root");
177
172 if (ENABLE_FEATURE_MDEV_CONF) chown(temp,uid,gid); 178 if (ENABLE_FEATURE_MDEV_CONF) chown(temp,uid,gid);
173 179
174end: 180end:
@@ -217,6 +223,11 @@ int mdev_main(int argc, char *argv[])
217 /* Scan */ 223 /* Scan */
218 224
219 if (argc == 2 && !strcmp(argv[1],"-s")) { 225 if (argc == 2 && !strcmp(argv[1],"-s")) {
226 struct stat st;
227
228 stat("/", &st); // If this fails, we have bigger problems.
229 root_major=major(st.st_dev);
230 root_minor=minor(st.st_dev);
220 strcpy(temp,"/sys/block"); 231 strcpy(temp,"/sys/block");
221 find_dev(temp); 232 find_dev(temp);
222 strcpy(temp,"/sys/class"); 233 strcpy(temp,"/sys/class");