chiark / gitweb /
rules: add persistent /dev/serial/{by-id,by-path} rules
[elogind.git] / extras / path_id / path_id
index a3a627e40794b00060af690a69656be3fab15b33..f45f62ad32eb1cf0a57e96e1ff1b895d357c0dd8 100755 (executable)
@@ -95,7 +95,11 @@ handle_pci () {
                                ;;
                esac
        done
-       d="pci-$pci_id-$d"
+       if [ "$d" ]; then
+               d="pci-$pci_id-$d"
+       else
+               d="pci-$pci_id"
+       fi
        D="$host_dev_path"
        RESULT=0
 }
@@ -250,7 +254,7 @@ handle_fc () {
        fc_tgt_lun="${fc_tgt_hcil##*:}"
        fc_tgt_path="${DEV%/*}"
        fc_tgt_num="${fc_tgt_path##*/}"
-       fc_tgt_dev="${fc_tgt_path}/fc_transport:${fc_tgt_num}"
+       fc_tgt_dev="${fc_tgt_path}/fc_transport/${fc_tgt_num}"
        if [ -e "$fc_tgt_dev/port_name" ]; then
                read wwpn < $fc_tgt_dev/port_name
        fi
@@ -511,6 +515,9 @@ handle_device () {
                        */host[0-9]*/[0-9]*:[0-9]*:[0-9]*:[0-9]*)
                                handle_scsi "$D"
                                ;;
+                       */ttyUSB*)
+                               D=${D%/ttyUSB*}
+                               ;;
                        */usb[0-9]*/[0-9]*/*)
                                handle_usb "$D"
                                ;;
@@ -549,7 +556,7 @@ handle_device () {
                                ;;
                        *)
                                mode=""
-                          ;;
+                               ;;
                esac
                if [ "$d" ]; then
                        d="$d-${rewind}st${mode}"
@@ -557,22 +564,9 @@ handle_device () {
        fi
 }
 
-case "$TYPE" in
-       block)
-               handle_device
-               echo "ID_PATH=$d"
-               ;;
-       scsi_tape)
-               handle_device
-               echo "ID_PATH=$d"
-               ;;
-       input)
-               handle_device
-               echo "ID_PATH=$d"
-               ;;
-       *)
-               RESULT=1
-               ;;
-esac
-
-exit $RESULT
+handle_device
+if [ -z "$d" ]; then
+       exit 1
+fi
+echo "ID_PATH=$d"
+exit 0