diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-06-08 14:56:49 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-06-08 14:56:49 +0200 |
commit | 7f011f6bf242b01ab684b13583590e529ff6acde (patch) | |
tree | 1bf2609d1558c7894bde0139c2d0f9672438a83e /extras/path_id | |
parent | b0d5e0df3e193a3beb4514a430c7ba62114845b6 (diff) |
path_id: handle fibre channel
Diffstat (limited to 'extras/path_id')
-rw-r--r-- | extras/path_id/path_id.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c index ce12e92c82..379334f02f 100644 --- a/extras/path_id/path_id.c +++ b/extras/path_id/path_id.c @@ -136,7 +136,40 @@ out: static struct udev_device *handle_fc(struct udev_device *parent, char **path) { - path_prepend(path, "fc-PATH_ID_NOT_IMPLEMENTED"); + struct udev *udev = udev_device_get_udev(parent); + struct udev_device *targetdev = NULL; + char *syspath = NULL; + struct udev_device *fcdev; + const char *port; + unsigned int lun; + + targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target"); + if (targetdev == NULL) { + parent = NULL; + goto out; + } + + if (asprintf(&syspath, "%s/fc_transport/%s", udev_device_get_syspath(targetdev), udev_device_get_sysname(targetdev)) < 0) { + parent = NULL; + goto out; + } + fcdev = udev_device_new_from_syspath(udev, syspath); + if (fcdev == NULL) { + parent = NULL; + goto out; + } + + port = udev_device_get_sysattr_value(fcdev, "port_name"); + if (port == NULL) { + parent = NULL; + goto out; + } + + lun = strtoul(udev_device_get_sysnum(parent), NULL, 10); + path_prepend(path, "fc-%s:0x%04x%04x00000000", port, lun & 0xffff, (lun >> 16) & 0xffff); +out: + free(syspath); + udev_device_unref(fcdev); return parent; } |