-}
-
-static int get_major_minor(struct sysfs_class_device *class_dev, int *maj,
- int *min)
-{
- struct sysfs_attribute *dev_attr;
-
- dev_attr = sysfs_get_classdev_attr(class_dev, "dev");
- if (!dev_attr) {
- /*
- * 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",
- class_dev->name, strerror(errno));
- return -1;
- }
-
- dprintf("dev value %s", dev_attr->value); /* value has a trailing \n */
- if (sscanf(dev_attr->value, "%u:%u", maj, min) != 2) {
- log_message(LOG_WARNING, "%s: invalid dev major/minor\n",
- class_dev->name);
- return -1;
- }
-
- return 0;
-}
-
-static int create_tmp_dev(struct sysfs_class_device *class_dev, char *tmpdev,
- int dev_type)
-{
- int maj, min;
-
- dprintf("(%s)\n", class_dev->name);
-
- if (get_major_minor(class_dev, &maj, &min))
- return -1;
- snprintf(tmpdev, MAX_NAME_LEN, "%s/%s-maj%d-min%d-%u",
- TMP_DIR, TMP_PREFIX, maj, min, getpid());
-
- dprintf("tmpdev '%s'\n", tmpdev);
-
- if (mknod(tmpdev, 0600 | dev_type, makedev(maj, min))) {
- log_message(LOG_WARNING, "mknod failed: %s\n", strerror(errno));
- return -1;
- }
- return 0;
-}
-
-static int has_sysfs_prefix(const char *path, const char *prefix)
-{
- char match[MAX_NAME_LEN];
-
- strncpy(match, sysfs_mnt_path, MAX_NAME_LEN);
- strncat(match, prefix, MAX_NAME_LEN);
- if (strncmp(path, match, strlen(match)) == 0)
- return 1;
- else
- return 0;