Skip to content

Commit

Permalink
Create /dev/root symlink pointing to real root device, if any.
Browse files Browse the repository at this point in the history
  • Loading branch information
landley committed Feb 21, 2006
1 parent c5789a6 commit a7e3d05
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions util-linux/mdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
Expand All @@ -27,6 +28,8 @@

#include <busybox.h>

int root_major, root_minor;

/* mknod in /dev based on a path like "/sys/block/hda/hda1" */
static void make_device(char *path)
{
Expand Down Expand Up @@ -169,6 +172,9 @@ static void make_device(char *path)
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:
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a7e3d05

Please sign in to comment.