diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/builtins.c | 1 | ||||
-rw-r--r-- | init/devices.c | 52 | ||||
-rwxr-xr-x | init/init.c | 2 |
3 files changed, 53 insertions, 2 deletions
diff --git a/init/builtins.c b/init/builtins.c index e0ccf9f..4326ebc 100644 --- a/init/builtins.c +++ b/init/builtins.c @@ -258,7 +258,6 @@ static struct { const char *name; unsigned flag; } mount_flags[] = { - { "move", MS_MOVE }, { "noatime", MS_NOATIME }, { "nosuid", MS_NOSUID }, { "nodev", MS_NODEV }, diff --git a/init/devices.c b/init/devices.c index d7aa3a6..5a580fa 100644 --- a/init/devices.c +++ b/init/devices.c @@ -261,6 +261,57 @@ static void parse_event(const char *msg, struct uevent *uevent) uevent->firmware, uevent->major, uevent->minor); } +static char **get_character_device_symlinks(struct uevent *uevent) +{ + const char *parent; + char *slash; + char **links; + int link_num = 0; + int width; + + if (strncmp(uevent->path, "/devices/platform/", 18)) + return NULL; + + links = malloc(sizeof(char *) * 2); + if (!links) + return NULL; + memset(links, 0, sizeof(char *) * 2); + + /* skip "/devices/platform/<driver>" */ + parent = strchr(uevent->path + 18, '/'); + if (!*parent) + goto err; + + if (!strncmp(parent, "/usb", 4)) { + /* skip root hub name and device. use device interface */ + while (*++parent && *parent != '/'); + if (*parent) + while (*++parent && *parent != '/'); + if (!*parent) + goto err; + slash = strchr(++parent, '/'); + if (!slash) + goto err; + width = slash - parent; + if (width <= 0) + goto err; + + if (asprintf(&links[link_num], "/dev/usb/%s%.*s", uevent->subsystem, width, parent) > 0) + link_num++; + else + links[link_num] = NULL; + mkdir("/dev/usb", 0755); + } + else { + goto err; + } + + return links; +err: + free(links); + return NULL; +} + static char **parse_platform_block_device(struct uevent *uevent) { const char *driver; @@ -404,6 +455,7 @@ static void handle_device_event(struct uevent *uevent) name += 4; } else base = "/dev/"; + links = get_character_device_symlinks(uevent); } if (!devpath_ready) diff --git a/init/init.c b/init/init.c index 8f95da7..98539b8 100755 --- a/init/init.c +++ b/init/init.c @@ -673,7 +673,7 @@ int main(int argc, char **argv) mkdir("/proc", 0755); mkdir("/sys", 0755); - mount("tmpfs", "/dev", "tmpfs", 0, "mode=0755"); + mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"); mkdir("/dev/pts", 0755); mkdir("/dev/socket", 0755); mount("devpts", "/dev/pts", "devpts", 0, NULL); |