- snprintf(temp, PATH_MAX, "%s/dev", path);
- fd = open(temp, O_RDONLY);
- len = read(fd, temp, PATH_MAX-1);
- if (len<1) goto end;
+/* mknod in /dev based on a path like "/sys/block/hda/hda1" */
+static void make_device(char *path)
+{
+ char *device_name, *s;
+ int major, minor, type, len, fd;
+ int mode = 0660;
+ uid_t uid = 0;
+ gid_t gid = 0;
+ char *temp = path + strlen(path);
+
+ /* Try to read major/minor string. Note that the kernel puts \n after
+ * the data, so we don't need to worry about null terminating the string
+ * because sscanf() will stop at the first nondigit, which \n is. We
+ * also depend on path having writeable space after it. */
+
+ strcat(path, "/dev");
+ fd = open(path, O_RDONLY);
+ len = read(fd, temp + 1, 64);
+ *temp++ = 0;