]> err.no Git - systemd/commitdiff
path_id: handle fibre channel
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 8 Jun 2009 12:56:49 +0000 (14:56 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 8 Jun 2009 12:56:49 +0000 (14:56 +0200)
extras/path_id/path_id.c
rules/rules.d/60-persistent-storage.rules

index ce12e92c82789fb287a562e74510df33009ce3a8..379334f02f60693dbe0abef446dc6e8718ce341c 100644 (file)
@@ -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;
 }
 
index b39ea0332148a9bf6ae9dbe5f14766d93b2f6b74..f4ac6a0277a2cb5fde17f1263cc3c2b52a33ed90 100644 (file)
@@ -47,8 +47,8 @@ KERNEL=="mspblk[0-9]", SUBSYSTEMS=="memstick", ATTRS{name}=="?*", ATTRS{serial}=
 KERNEL=="mspblk[0-9]p[0-9]", ENV{ID_NAME}=="?*", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/memstick-$env{ID_NAME}_$env{ID_SERIAL}-part%n"
 
 # by-path (parent device path)
-# old shell script for fc, sas, iscsi, s390, ide
-ENV{DEVTYPE}=="disk", DEVPATH=="*/css0/*|*/rport-[0-9]*|*/end_device-*|*/session[0-9]*|*/ide[0-9]*", IMPORT{program}="path_id.sh %p"
+# old shell script for sas, iscsi, ide
+ENV{DEVTYPE}=="disk", DEVPATH=="*/end_device-*|*/session[0-9]*|*/ide[0-9]*", IMPORT{program}="path_id.sh %p"
 ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{program}="path_id %p"
 ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
 ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"