chiark / gitweb /
[PATCH] Minor POSIX-fixes for udev
authortao@kernel.org <tao@kernel.org>
Wed, 11 Aug 2004 08:03:03 +0000 (01:03 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:36:59 +0000 (21:36 -0700)
The attached patch contains a few patches against udev, to remove
use of various XSI:isms and bash:isms, and to change two scripts form
/bin/bash to /bin/sh.  None of the bash-scripts in test/ uses any
bash-specific functions as far as I know, but I didn't touch them since
they aren't used runtime.

Rationale:
* Both of the /bin/bash-scripts are totally free from bashisms, hence they
  don't need to be /bin/bash; using /bin/sh instead helps (mainly)
  embedded-people

* local and source are bash:isms (well, they exist in several other
  shells as well, but they aren't part of POSIX or any of its extensions)

* -a in tests is an XSI-extension, not part of strict POSIX, and is
  easily replaced by &&
  | http://www.opengroup.org/onlinepubs/009695399/utilities/test.html

* Use of fgrep is deprecated in POSIX in favour of grep -F (though fgrep
  will remain in use for a long time...)
  | http://www.opengroup.org/onlinepubs/009695399/utilities/grep.html

The fgrep-change isn't really necessary, since fgrep can always be
implemented as a shell-script, but the rest of the changes would really
be appreciated.

etc/dev.d/default/pam_console.dev
etc/dev.d/default/selinux.dev
etc/init.d/udev
etc/init.d/udev.debian
etc/init.d/udev.init.lfs
extras/ide-devfs.sh
extras/scsi-devfs.sh
extras/start_udev

index 7e95810e2c3d8bef9fc5417c151539cbcb971f1b..563051d7f61ba77224b15b627c87a9808a4e1dbd 100644 (file)
@@ -11,7 +11,7 @@ fi
 [ "$UDEV_CONSOLE" != "yes" ] && exit 0
 
 if [ -x /sbin/pam_console_setowner ]; then
-       if [ "$UDEV_LOG" = "yes" -a -x /usr/bin/logger ]; then 
+       if [ "$UDEV_LOG" = "yes" ] && [ -x /usr/bin/logger ]; then 
                /usr/bin/logger -p auth.debug "Restoring console permissions for $DEVNAME"
        fi
        exec /sbin/pam_console_setowner $DEVNAME
index 7911d345b998676492da69ed13e48e9f6d3b76f7..9682658aad73c0797289b27b954090dc137d9e66 100644 (file)
@@ -11,7 +11,7 @@ fi
 [ "$UDEV_SELINUX" != "yes" ] && exit 0
 
 if [ -x /sbin/restorecon ]; then
-       if [ "$UDEV_LOG" = "yes" -a -x /usr/bin/logger ]; then
+       if [ "$UDEV_LOG" = "yes" ] && [ -x /usr/bin/logger ]; then
                /usr/bin/logger -p auth.debug "Restoring file security contexts for $DEVNAME"
        fi
        /sbin/restorecon $DEVNAME
index cd9074de091315a66c1b1cc65a883a66d66ef6c2..7e6305a45b9d4c91101497144abe68ce7eac8137 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # udev init script to setup /udev
 #
index 776a73644cd7c5bab3563bfd6c75ccbbebb25cc0..8268fe6c2f57531d490b0b84f2cd2d3b3c2bfdf1 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # random       init script to setup /udev
 #
index c7383690813f877e159a1a54cf0b420c6b1bf461..41a3fecf0ffce04d0da1ed5f2391f3a9dbc3e631 100644 (file)
@@ -5,9 +5,9 @@
 #  2003, 2004 by Michael Buesch <mbuesch@freenet.de>
 #
 
-source /etc/sysconfig/rc
-source $rc_functions
-source /etc/udev/udev.conf
+. /etc/sysconfig/rc
+. $rc_functions
+. /etc/udev/udev.conf
 
 sysfs_dir="/sys"
 bin="/sbin/udev"
index 4d021c5e8723ccd18554c127b7c91a3ed107e5f2..4f202594801f3354410189b978a301eba47033b3 100644 (file)
@@ -15,15 +15,13 @@ else
 fi
 
 get_dev_number() {
-       local x=
-       local num=0
-       local MEDIA=
-       local DRIVE="${1%%[0-9]*}"
+       num=0
+       DRIVE="${1%%[0-9]*}"
 
        for x in /proc/ide/*/media; do
                if [ -e "${x}" ]; then
-                       MEDIA=`cat ${x}`
-                       if [ "${MEDIA}" = "$2" ]; then
+                       lMEDIA=`cat ${x}`
+                       if [ "${lMEDIA}" = "$2" ]; then
                                num=$((${num} + 1))
                        fi
                        if [ "${x}" = "/proc/ide/${DRIVE}/media" ]; then
@@ -35,7 +33,7 @@ get_dev_number() {
        echo $((${num} - 1))
 }
 
-if [ -z "$3" -a -f /proc/ide/${1}/media ]; then
+if [ -z "$3" ] && [ -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`
index 30f4553a5bc29c38de565e633361415383a4d436..12c8aa8eb5b022c502b3af899fd719260ce0d327 100644 (file)
@@ -14,7 +14,7 @@
 # BUS="scsi", KERNEL="sg*", PROGRAM="/etc/udev/scsi-devfs.sh sg %b %n", NAME="%c{1}", SYMLINK="%c{2} %k %c{3} %c{4}"
 
 # Find out where sysfs is mounted. Exit if not available
-sysfs=`fgrep sysfs /proc/mounts | awk '{print $2}'`
+sysfs=`grep -F sysfs /proc/mounts | awk '{print $2}'`
 if [ "$sysfs" = "" ]; then
     echo "sysfs is required"
     exit 1
@@ -63,7 +63,7 @@ s_com="b${scsi_bus}t${scsi_target}u${scsi_lun}$spart"
 l_log="scsi/host$scsi_host/$l_com"
 s_log="$1/c${scsi_host}${s_com}"
 
-readlink $2 | fgrep -q pci
+readlink $2 | grep -F -q pci
 if [ "$?" != "0" ]; then
     # Not a PCI controller, show logical locations only
     echo $l_log $s_log
index 4908d05b708e003d5646853d37ecef337e1d2298..bbf32a1bb9befb81940c2481d4f76503e9527737 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # start_udev
 #