]> git.pld-linux.org Git - packages/hdparm.git/blobdiff - hdparm.init
- allow using disk labels from /dev/disk/by-id
[packages/hdparm.git] / hdparm.init
index 1f6ddb9a24a2b0685e3f06dfc030946b0999d144..40f7db062faa4ad9233fa0c43a47c75d5b0750de 100644 (file)
@@ -15,12 +15,25 @@ fi
 
 for var in $blockdevs; do
        drive=${var#HDPARM_}
-       if [ -L "/proc/ide/${drive}" -o -d "/sys/block/${drive}" ]; then
+
+       # check if it is some ID
+       if [ -L /dev/disk/by-id/ata-$drive ]; then
+               dev=$(readlink -f /dev/disk/by-id/ata-$drive)
+       elif [ -L /dev/disk/by-id/scsi-$dev ]; then
+               dev=$(readlink -f /dev/disk/by-id/scsi-$drive)
+       else
+               dev=$drive
+       fi
+
+       # strip /dev
+       dev=${dev#/dev/}
+
+       if [ -L "/proc/ide/$dev" -o -d "/sys/block/$dev" ]; then
                eval PARAMS=\$$var
-               if [ -n "${PARAMS}" ]; then
+               if [ -n "$PARAMS" ]; then
                        show "Setting parameters for drive %s (%s)" "$drive" "$PARAMS"
                        busy
-                       /sbin/hdparm ${PARAMS} /dev/${drive}
+                       /sbin/hdparm $PARAMS /dev/$dev
                        ok
                fi
        fi
This page took 0.168716 seconds and 4 git commands to generate.