chiark / gitweb /
[PATCH] add install and uninstall the etc/dev.d/net/hotplug.dev file to the Makefile
[elogind.git] / extras / ide-devfs.sh
index 1cf6f9c9e463aaf3d43be8f2a177aeb05e1098c1..22d09d7a5ac0efc8768504b9b874325c8d4f05db 100644 (file)
@@ -2,13 +2,13 @@
 
 # udev external PROGRAM script
 # return devfs-names for ide-devices
-# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%1c %2c"
+# BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}"
 
 HOST="${2%\.[0-9]}"
 TARGET="${2#[0-9]\.}"
 
 if [ -z "${HOST#[13579]}" ]; then
-       HOST=`expr ${HOST} - 1`
+       HOST=$((${HOST} - 1))
        BUS="1"
 else
        BUS="0"
@@ -24,7 +24,7 @@ get_dev_number() {
                if [ -e "${x}" ]; then
                        MEDIA=`cat ${x}`
                        if [ "${MEDIA}" = "$2" ]; then
-                               num=`expr ${num} + 1`
+                               num=$((${num} + 1))
                        fi
                        if [ "${x}" = "/proc/ide/${DRIVE}/media" ]; then
                                break
@@ -32,10 +32,10 @@ get_dev_number() {
                fi
        done
        
-       echo `expr ${num} - 1`
+       echo $((${num} - 1))
 }
 
-if [ -z "$3" ]; then
+if [ -z "$3" -a -f /proc/ide/${1}/media ]; then
        MEDIA=`cat /proc/ide/${1}/media`
        if [ "${MEDIA}" = "cdrom" ]; then
                echo ide/host${HOST}/bus${BUS}/target${TARGET}/lun0/cd cdroms/cdrom`get_dev_number $1 cdrom`