- char callout[MAX_NAME_LEN];
-
- dprintf("target_path %s\n", target_path);
-
- /*
- * Ugly: depend on the sysfs path to tell us whether this is a
- * block or char device. This should probably be encoded in the
- * "dev" along with the major/minor.
- */
- if (has_sysfs_prefix(target_path, "/block")) {
- dev_type = S_IFBLK;
- } else if (has_sysfs_prefix(target_path, "/class")) {
- dev_type = S_IFCHR;
- } else {
- if (!hotplug_mode) {
- log_message(LOG_WARNING,
- "Non block or class device '%s'\n",
- target_path);
- return 1;
- } else {
- /*
- * Expected in some cases.
- */
- dprintf("Non block or class device\n");
- return 0;
- }
- }
-
- class_dev = sysfs_open_class_device_path(target_path);
- if (!class_dev) {
- log_message(LOG_WARNING, "open class %s failed: %s\n",
- target_path, strerror(errno));
- return 1;
- }
- class_dev_parent = sysfs_get_classdev_parent(class_dev);
- dprintf("class_dev 0x%p; class_dev_parent 0x%p\n", class_dev,
- class_dev_parent);
- if (class_dev_parent) {
- scsi_dev = sysfs_get_classdev_device(class_dev_parent);
- } else {
- scsi_dev = sysfs_get_classdev_device(class_dev);
- }
-
- /*
- * The close of scsi_dev will close class_dev or class_dev_parent.
- */
-
- /*
- * We assume we are called after the device is completely ready,
- * so we don't have to loop here like udev. (And we are usually
- * called via udev.)
- */
- if (!scsi_dev) {
- /*
- * errno is not set if we can't find the device link, so
- * don't print it out here.
- */
- log_message(LOG_WARNING, "Cannot find sysfs device associated with %s\n",
- target_path);
- return 1;
- }