chiark / gitweb /
man: fix typos
[elogind.git] / extras / path_id / path_id
index 57879b5a9a0a1e4b21f842845e4d6c0f5d59677f..0fad30cfb257d3468ce047efaf1776994be04f3c 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
 }
@@ -456,7 +460,11 @@ handle_device () {
                                        return
                                fi
                        fi
-                       cd $full_sysfs_path/device
+                       if [ -L $full_sysfs_path/device/device ]; then
+                               cd $full_sysfs_path/device/device
+                       else
+                               cd $full_sysfs_path/device
+                       fi
                        ;;
        esac
        full_sysfs_device_path="`pwd -P`"
@@ -545,7 +553,7 @@ handle_device () {
                                ;;
                        *)
                                mode=""
-                          ;;
+                               ;;
                esac
                if [ "$d" ]; then
                        d="$d-${rewind}st${mode}"
@@ -553,22 +561,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