chiark / gitweb /
[PATCH] fix scsi_id segfault with udev-009
authordsteklof@us.ibm.com <dsteklof@us.ibm.com>
Thu, 18 Dec 2003 03:05:25 +0000 (19:05 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:09 +0000 (21:13 -0700)
Scsi_id hasn't been changed to use the latest libsysfs changes. The
"directory" in the sysfs_class_device is now considered "private" and only
should be accessed using functions. Treating the structures as handles lets
us only load information when it's needed, reducing caching or stale
information and also helping performance.

Here's the problem.

static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
                                    const char *attr)
{
        return sysfs_get_value_from_attributes(dev->directory->attributes,
                                               attr);
}

Please try this quick fix:

extras/scsi_id/scsi_id.c
extras/scsi_id/scsi_id.h

index df18271b48834e2febabc33350f4b7a4ee206833..3a34643c81b7175c9847eae1c287029c47228c9c 100644 (file)
@@ -133,7 +133,7 @@ static int sysfs_is_bus(const char *sysfs_path, const char *bus)
                return -1;
 
        snprintf(bus_dev_name, MAX_NAME_LEN, "%s/%s/%s/%s/%s", sysfs_mnt_path,
-                SYSFS_BUS_DIR, bus, SYSFS_DEVICES_NAME, bus_id);
+                SYSFS_BUS_NAME, bus, SYSFS_DEVICES_NAME, bus_id);
 
        if (stat(sysfs_path, &stat_buf))
                return -1;
index eb9498ab71f0fb35a9b5eaac491c605f1d9a38a0..cb27e88a5f308707a558559c3060513908ee4c57 100644 (file)
 static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
                                    const char *attr)
 {
-       return sysfs_get_value_from_attributes(dev->directory->attributes,
-                                              attr);
+       struct dlist *attributes = NULL;
+
+       attributes = sysfs_get_classdev_attributes(dev);
+
+       if (attributes == NULL)
+               return NULL;
+
+       return sysfs_get_value_from_attributes(attributes, attr);
 }
 
 extern int scsi_get_serial (struct sysfs_class_device *scsi_dev,