From: tao@kernel.org Date: Wed, 11 Aug 2004 08:03:03 +0000 (-0700) Subject: [PATCH] Minor POSIX-fixes for udev X-Git-Tag: 031~15 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=b9e3301c3b68a1c6464a0bf0ac6e61fc0e4063d1;hp=2410242aa4d21335026d3b90116078c9146a32f3 [PATCH] Minor POSIX-fixes for udev 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. --- diff --git a/etc/dev.d/default/pam_console.dev b/etc/dev.d/default/pam_console.dev index 7e95810e2..563051d7f 100644 --- a/etc/dev.d/default/pam_console.dev +++ b/etc/dev.d/default/pam_console.dev @@ -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 diff --git a/etc/dev.d/default/selinux.dev b/etc/dev.d/default/selinux.dev index 7911d345b..9682658aa 100644 --- a/etc/dev.d/default/selinux.dev +++ b/etc/dev.d/default/selinux.dev @@ -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 diff --git a/etc/init.d/udev b/etc/init.d/udev index cd9074de0..7e6305a45 100644 --- a/etc/init.d/udev +++ b/etc/init.d/udev @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # udev init script to setup /udev # diff --git a/etc/init.d/udev.debian b/etc/init.d/udev.debian index 776a73644..8268fe6c2 100644 --- a/etc/init.d/udev.debian +++ b/etc/init.d/udev.debian @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # random init script to setup /udev # diff --git a/etc/init.d/udev.init.lfs b/etc/init.d/udev.init.lfs index c73836908..41a3fecf0 100644 --- a/etc/init.d/udev.init.lfs +++ b/etc/init.d/udev.init.lfs @@ -5,9 +5,9 @@ # 2003, 2004 by Michael Buesch # -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" diff --git a/extras/ide-devfs.sh b/extras/ide-devfs.sh index 4d021c5e8..4f2025948 100644 --- a/extras/ide-devfs.sh +++ b/extras/ide-devfs.sh @@ -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` diff --git a/extras/scsi-devfs.sh b/extras/scsi-devfs.sh index 30f4553a5..12c8aa8eb 100644 --- a/extras/scsi-devfs.sh +++ b/extras/scsi-devfs.sh @@ -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 diff --git a/extras/start_udev b/extras/start_udev index 4908d05b7..bbf32a1bb 100644 --- a/extras/start_udev +++ b/extras/start_udev @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # start_udev #