diff options
Diffstat (limited to 'toys/pending')
-rw-r--r-- | toys/pending/mdev.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/toys/pending/mdev.c b/toys/pending/mdev.c index a13a53df..e7adc993 100644 --- a/toys/pending/mdev.c +++ b/toys/pending/mdev.c @@ -24,7 +24,7 @@ config MDEV_CONF hd[a-z][0-9]* 0:3 660 Each line must contain three whitespace separated fields. The first - field is a regular expression matching one or more device names, and + field is a regular expression matching one or more device names, the second and third fields are uid:gid and file permissions for matching devies. */ @@ -34,9 +34,8 @@ config MDEV_CONF // mknod in /dev based on a path like "/sys/block/hda/hda1" static void make_device(char *path) { - char *device_name = NULL, *s, *temp; - int major = 0, minor = 0, type, len, fd; - int mode = 0660; + char *device_name = 0, *s, *temp; + int major = 0, minor = 0, type, len, fd, mode = 0660; uid_t uid = 0; gid_t gid = 0; @@ -45,7 +44,7 @@ static void make_device(char *path) temp = strrchr(path, '/'); fd = open(path, O_RDONLY); - *temp=0; + *temp = 0; len = read(fd, toybuf, 64); close(fd); if (len<1) return; @@ -58,19 +57,15 @@ static void make_device(char *path) } else { // if (!path), do hotplug - if (!(temp = getenv("SUBSYSTEM"))) - return; + if (!(temp = getenv("MODALIAS"))) xrun((char *[]){"modprobe", temp, 0}); + if (!(temp = getenv("SUBSYSTEM"))) return; type = strcmp(temp, "block") ? S_IFCHR : S_IFBLK; - if (!(temp = getenv("MAJOR"))) - return; + if (!(temp = getenv("MAJOR"))) return; sscanf(temp, "%u", &major); - if (!(temp = getenv("MINOR"))) - return; + if (!(temp = getenv("MINOR"))) return; sscanf(temp, "%u", &minor); - path = getenv("DEVPATH"); + if (!(path = getenv("DEVPATH"))) return; device_name = getenv("DEVNAME"); - if (!path) - return; } if (!device_name) device_name = strrchr(path, '/') + 1; |