diff options
| author | Rob Landley <rob@landley.net> | 2006-02-21 06:11:13 +0000 |
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2006-02-21 06:11:13 +0000 |
| commit | a7e3d0520856db27744b4a33e786123d44bf5b2a (patch) | |
| tree | 5d646cbcf9a1218ba4cd09a86681f0affa2652a4 /util-linux/mdev.c | |
| parent | c5789a6e234c1ddec204cf65f319babb04ca6a47 (diff) | |
| download | busybox-w32-a7e3d0520856db27744b4a33e786123d44bf5b2a.tar.gz busybox-w32-a7e3d0520856db27744b4a33e786123d44bf5b2a.tar.bz2 busybox-w32-a7e3d0520856db27744b4a33e786123d44bf5b2a.zip | |
Create /dev/root symlink pointing to real root device, if any.
Diffstat (limited to 'util-linux/mdev.c')
| -rw-r--r-- | util-linux/mdev.c | 11 |
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 | ||
| 31 | int 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" */ |
| 31 | static void make_device(char *path) | 34 | static 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 | ||
| 174 | end: | 180 | end: |
| @@ -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"); |
