- char attr_path[SYSFS_PATH_MAX];
-
- strncpy(attr_path, devpath, SYSFS_PATH_MAX);
- strncat(attr_path, "/", SYSFS_PATH_MAX);
- strncat(attr_path, attr, SYSFS_PATH_MAX);
- dprintf("%s\n", attr_path);
- return sysfs_read_attribute_value(attr_path, value, SYSFS_NAME_LEN);
-}
-
-static int get_major_minor(const char *devpath, int *major, int *minor)
-{
- char dev_value[MAX_ATTR_LEN];
-
- if (sysfs_get_attr(devpath, "dev", dev_value, MAX_ATTR_LEN)) {
- /*
- * XXX This happens a lot, since sg has no dev attr.
- * And now sysfsutils does not set a meaningful errno
- * value. Someday change this back to a LOG_WARNING.
- * And if sysfsutils changes, check for ENOENT and handle
- * it separately.
- */
- log_message(LOG_DEBUG, "%s: could not get dev attribute: %s\n",
- devpath, strerror(errno));
- return -1;
- }
-
- dprintf("dev value %s", dev_value); /* dev_value has a trailing \n */
- if (sscanf(dev_value, "%u:%u", major, minor) != 2) {
- log_message(LOG_WARNING, "%s: invalid dev major/minor\n",
- devpath);
- return -1;
- }
-
- return 0;
-}
-
-static int create_tmp_dev(const char *devpath, char *tmpdev, int dev_type)
-{
- int major, minor;
-
- dprintf("(%s)\n", devpath);
-
- if (get_major_minor(devpath, &major, &minor))
- return -1;
- snprintf(tmpdev, MAX_NAME_LEN, "%s/%s-maj%d-min%d-%u",
- TMP_DIR, TMP_PREFIX, major, minor, getpid());
-
- dprintf("tmpdev '%s'\n", tmpdev);
-
- if (mknod(tmpdev, 0600 | dev_type, makedev(major, minor))) {
- log_message(LOG_WARNING, "mknod failed: %s\n", strerror(errno));
- return -1;