- 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 sysfs_get_actual_dev(const char *sysfs_path, char *dev, int len)
-{
- dprintf("%s\n", sysfs_path);
- strncpy(dev, sysfs_path, len);
- strncat(dev, "/device", len);
- if (sysfs_get_link(dev, dev, len)) {
- if (!hotplug_mode)
- log_message(LOG_WARNING, "%s: %s\n", dev,
- strerror(errno));
- return -1;
- }
- return 0;
-}
-
-/*
- * sysfs_is_bus: Given the sysfs_path to a device, return 1 if sysfs_path
- * is on bus, 0 if not on bus, and < 0 on error
- */
-static int sysfs_is_bus(const char *sysfs_path, const char *bus)
-{
- char bus_dev_name[SYSFS_PATH_MAX];
- char bus_id[SYSFS_NAME_LEN];
- struct stat stat_buf;
- ino_t dev_inode;
-
- dprintf("%s\n", sysfs_path);
-
- if (sysfs_get_name_from_path(sysfs_path, bus_id, SYSFS_NAME_LEN))
- return -1;
-
- snprintf(bus_dev_name, MAX_NAME_LEN, "%s/%s/%s/%s/%s", sysfs_mnt_path,
- SYSFS_BUS_NAME, bus, SYSFS_DEVICES_NAME, bus_id);
-
- if (stat(sysfs_path, &stat_buf))
- return -1;
- dev_inode = stat_buf.st_ino;
-
- if (stat(bus_dev_name, &stat_buf)) {
- if (errno == ENOENT)
- return 0;
- else
- return -1;
- }
- if (dev_inode == stat_buf.st_ino)
- return 1;
- else
- return 0;
-}
-
-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;