diff options
author | Krzysztof Wojcik <krzysztof.wojcik@intel.com> | 2011-02-18 23:51:34 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-02-18 23:51:34 +1100 |
commit | fa89bdeeafd200e8b496ba34da2fa54317093309 (patch) | |
tree | b1199ce050c8455218d957db3ced49d9fa7a71fd /sysfs.c | |
parent | c4db530180e77ecf3fe0920b0f5c563655859dc1 (diff) |
FIX: sysfs_disk_to_scsi_id() adapted to current sysfs format
Problem: sysfs_disk_to_scsi_id() not returns correct scsi_id value.
Reason: sysfs format has been changed
This patch adapt sysfs_disk_to_scsi_id() to new sysfs format.
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -705,7 +705,7 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id) if (fstat(fd, &st)) return 1; - snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/device", + snprintf(path, sizeof(path), "/sys/dev/block/%d:%d/device/scsi_device", major(st.st_rdev), minor(st.st_rdev)); dir = opendir(path); @@ -714,8 +714,7 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id) de = readdir(dir); while (de) { - if (strncmp("scsi_disk:", de->d_name, - strlen("scsi_disk:")) == 0) + if (strchr(de->d_name, ':')) break; de = readdir(dir); } @@ -724,21 +723,20 @@ int sysfs_disk_to_scsi_id(int fd, __u32 *id) if (!de) return 1; - c1 = strchr(de->d_name, ':'); - c1++; + c1 = de->d_name; c2 = strchr(c1, ':'); *c2 = '\0'; *id = strtol(c1, NULL, 10) << 24; /* host */ c1 = c2 + 1; c2 = strchr(c1, ':'); *c2 = '\0'; - *id |= strtol(c1, NULL, 10) << 16; /* channel */ + *id |= strtol(c1, NULL, 10) << 16; /* bus */ c1 = c2 + 1; c2 = strchr(c1, ':'); *c2 = '\0'; - *id |= strtol(c1, NULL, 10) << 8; /* lun */ + *id |= strtol(c1, NULL, 10) << 8; /* target */ c1 = c2 + 1; - *id |= strtol(c1, NULL, 10); /* id */ + *id |= strtol(c1, NULL, 10); /* lun */ return 0; } |