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.
*/
// 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;
temp = strrchr(path, '/');
fd = open(path, O_RDONLY);
- *temp=0;
+ *temp = 0;
len = read(fd, toybuf, 64);
close(fd);
if (len<1) return;
} 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;