From: Joerg Sommer <joerg@alea.gnuu.de>
To: linux-hotplug@vger.kernel.org
Subject: Some questions
Date: Tue, 19 Aug 2003 15:53:48 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-106132906900805@msgid-missing> (raw)
Hi,
I've downloaded hotplug-2003_08_05 and have some questions about the code:
* Why not remove the bashism?
sbin/hotplug:
* Why not include the test for -x in the if expression?
if [ -f $I -a -x $I ]; then
$I $1 ;
fi
* Why returns this script with exit code 1? Doesn't this stand for an
error?
#v+
diff -ur hotplug-2003_08_05.orig/sbin/hotplug hotplug-2003_08_05/sbin/hotplug
--- hotplug-2003_08_05.orig/sbin/hotplug 2003-06-28 02:13:10.000000000 +0
+++ hotplug-2003_08_05/sbin/hotplug 2003-08-19 16:21:38.000000000 +0200
@@ -28,8 +28,8 @@
DIR="/etc/hotplug.d"
for I in "${DIR}/$1/"*.hotplug "${DIR}/"default/*.hotplug ; do
- if [ -f $I ]; then
- test -x $I && $I $1 ;
+ if [ -f $I -a -x $I ]; then
+ $I $1
fi
done
#v-
etc/hotplug.d/default/default.hotplug:
* l.46: Why use sed to strip the tailing .agent? This causes a pipe
and another command, even though, this could be done by basename.
* l.67: Why do you debug handling by hand? There is a function
debug_mesg, so this shouldn't be necessary.
* If default.hotplug is called in the right way, you check, if the agent
is executable. If not, it fails. So you can't name nonexecutable agents
in l.53.
* I think a $(set -e) is essential, because a cd to /etc/hotplug could
fail.
* To source hotplug.functions a path must be named, otherwise
hotplug.functions is searched in the directories of $PATH, which should
fail. See Posix 1003.2 3.14.4.
#v+
diff -ur hotplug-2003_08_05.orig/etc/hotplug.d/default/default.hotplug hotplug-2003_08_05/etc/hotplug.d/default/default.hotplug
--- hotplug-2003_08_05.orig/etc/hotplug.d/default/default.hotplug 2003-05-02 07:01:45.000000000 +0200
+++ hotplug-2003_08_05/etc/hotplug.d/default/default.hotplug 2003-08-19 16:26:07.000000000 +0200
@@ -23,10 +23,12 @@
# $Id: default.hotplug,v 1.1 2003/05/02 05:01:45 kroah Exp $
#
-cd /etc/hotplug
-. hotplug.functions
+set -e
+
+# export DEBUG=yes
-# DEBUG=yes export DEBUG
+cd /etc/hotplug
+. ./hotplug.functions
debug_mesg "arguments ($*) env (`env`)"
@@ -38,19 +40,16 @@
# through argv.
#
if [ $# -lt 1 -o "$1" = "help" -o "$1" = "--help" ]; then
- if [ -t ]; then
+ if [ -t 1 ]; then
echo "Usage: $0 AgentName [AgentArguments]"
- AGENTS=""
- for AGENT in /etc/hotplug/*.agent ; do
- TYPE=`basename $AGENT | sed s/.agent//`
+ printf "AgentName values on this system:"
+ for AGENT in $HOTPLUG_DIR/*.agent ; do
if [ -x $AGENT ]; then
- AGENTS="$AGENTS $TYPE"
- else
- AGENTS="$AGENTS ($TYPE)"
+ printf " `basename $AGENT .agent`"
fi
done
- echo "AgentName values on this system: $AGENTS"
+ echo
else
mesg "illegal usage $*"
fi
@@ -61,12 +60,10 @@
# Delegate event handling:
# /sbin/hotplug FOO ..args.. ==> /etc/hotplug/FOO.agent ..args..
#
-AGENT=/etc/hotplug/$1.agent
+AGENT=$HOTPLUG_DIR/$1.agent
if [ -x $AGENT ]; then
shift
- if [ "$DEBUG" != "" ]; then
- mesg "invoke $AGENT ($@)"
- fi
+ debug_mesg "invoke $AGENT ($@)"
exec $AGENT "$@"
mesg "couldn't exec $AGENT"
exit 1
#v-
etc/hotplug/hotplug.functions:
* Posix logger doesn't know the option -t. If you depend on BSD logger,
it may be possible to specify the priority of the messages. In this
case, I would propose to add a function error_mesg(), hat logs on
stderr or use level debug for logger. As a whole, I would propose in
this case, to log to facility daemon.
#v+
diff -ur hotplug-2003_08_05.orig/etc/hotplug/hotplug.functions hotplug-2003_08_05/etc/hotplug/hotplug.functions
--- hotplug-2003_08_05.orig/etc/hotplug/hotplug.functions 2003-06-28 02:13:10.000000000 +0200
+++ hotplug-2003_08_05/etc/hotplug/hotplug.functions 2003-08-19 17:36:55.000000000 +0200
@@ -10,7 +10,7 @@
#
#
-# DEBUG=yes; export DEBUG
+# export DEBUG=yes
PATH=/bin:/sbin:/usr/sbin:/usr/bin
KERNEL=`uname -r`
@@ -22,31 +22,31 @@
. /etc/sysconfig/hotplug
fi
-if [ -x /usr/bin/logger ]; then
- LOGGER=/usr/bin/logger
-elif [ -x /bin/logger ]; then
- LOGGER=/bin/logger
-else
- unset LOGGER
-fi
#
# for diagnostics
#
-if [ -t -o -z "$LOGGER" ]; then
+if [ -t 1 -o ! \( -x /usr/bin/logger -o -x /bin/logger \) ]; then
mesg () {
echo "$@"
}
+ if [ "$DEBUG" = yes ]; then
+ debug_mesg () {
+ echo "$@"
+ }
+ else
+ debug_mesg () {
+ :
+ }
+ fi
else
mesg () {
- $LOGGER -t $(basename $0)"[$$]" "$@"
+ logger $(basename $0)"[$$] $@"
+ }
+ debug_mesg () {
+ logger $(basename $0)"[$$] $@"
}
fi
-debug_mesg () {
- test "$DEBUG" = "" -o "$DEBUG" = no && return
- mesg "$@"
-}
-
#
# The modules.*map parsing uses BASH ("declare -i") and some version
# of AWK, typically /bin/gawk. Most GNU/Linux distros have these,
@@ -80,23 +80,18 @@
#
load_drivers ()
{
- local LOADED TYPE FILENAME DESCRIPTION LISTER
- DRIVERS=""
-
# make this routine more readable
TYPE=$1
FILENAME=$2
DESCRIPTION=$3
+ DRIVERS=""
# should we use usbmodules, pcimodules? not on 2.5+, because sysfs
# ought to expose the data we need to find all candidate drivers.
# (on 2.5.48 it does for usb; but maybe not yet for pci.)
case "$KERNEL" in
- 2.2*|2.3*|2.4*) LISTER=`type -p ${TYPE}modules` ;;
- *) LISTER="" ;;
- esac
-
- if [ "$LISTER" != "" ]; then
+ 2.2*|2.3*|2.4*)
+ LISTER=`type -p ${TYPE}modules`
# lister programs MIGHT be preferable to parsing from shell scripts:
# - usbmodules used for (a) multi-interface devices, (b) coldplug
# - pcimodules used only for coldplug
@@ -106,27 +101,26 @@
# only works if we have usbfs
# ... reads more descriptors than are passed in env
# ... doesn't handle comment syntax either
- if [ "$DEVICE" = "" -o ! -f "$DEVICE" ]; then
- LISTER=
- else
+ if [ -f "$DEVICE" ]; then
DRIVERS=`$LISTER --mapfile $FILENAME --device $DEVICE`
- fi ;;
-
+ fi
+ ;;
pci)
debug_mesg "pcimodules is scanning more than $PCI_SLOT ..."
DRIVERS=`$LISTER`
;;
esac
- fi
+ ;;
+ esac
# try parsing by shell scripts if no luck yet
- if [ "$DRIVERS" = "" ]; then
+ if [ -z "$DRIVERS" ]; then
${TYPE}_map_modules < $FILENAME
fi
# FIXME remove dups and blacklisted modules from $DRIVERS here
- if [ "$DRIVERS" = "" ]; then
+ if [ -z "$DRIVERS" ]; then
return
fi
@@ -139,9 +133,8 @@
do
# maybe driver modules need loading
LOADED=false
- if ! lsmod | grep -q "^$MODULE " > /dev/null 2>&1; then
- if grep -q "^$MODULE\$" $HOTPLUG_DIR/blacklist \
- >/dev/null 2>&1; then
+ if ! lsmod | grep -q "^$MODULE "; then
+ if grep -q "^$MODULE\$" $HOTPLUG_DIR/blacklist; then
debug_mesg "... blacklisted module: $MODULE"
continue
fi
@@ -167,8 +160,7 @@
# giving kernel code another chance.
if [ -x $HOTPLUG_DIR/$TYPE/$MODULE ]; then
debug_mesg Module setup $MODULE for $DESCRIPTION
- $HOTPLUG_DIR/$TYPE/$MODULE
- LOADED=true
+ $HOTPLUG_DIR/$TYPE/$MODULE && LOADED=true
fi
if [ $LOADED = false ]; then
#v-
Bye, Joerg.
--
»Perl - the only language that looks the same
before and after RSA encryption.« -- Keith Bostic
-------------------------------------------------------
This SF.net email is sponsored by Dice.com.
Did you know that Dice has over 25,000 tech jobs available today? From
careers in IT to Engineering to Tech Sales, Dice has tech jobs from the
best hiring companies. http://www.dice.com/index.epl?rel_code\x104
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next reply other threads:[~2003-08-19 15:53 UTC|newest]
Thread overview: 132+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-19 15:53 Joerg Sommer [this message]
[not found] <CAGEeD9YPvDhbt7KFvLOJ6W99UM_Jck6PFF6HV2h=B5u2gChggg@mail.gmail.com>
2017-10-04 6:58 ` Some questions Никита Горбунов
2017-10-05 6:09 ` Sitsofe Wheeler
-- strict thread matches above, loose matches on Subject: below --
2016-04-27 15:21 Akira Yokosawa
[not found] ` <20160427165357.GD4967@linux.vnet.ibm.com>
2016-04-27 22:15 ` Akira Yokosawa
2016-04-27 22:50 ` Paul E. McKenney
2016-04-27 23:01 ` Akira Yokosawa
2016-04-27 23:28 ` Paul E. McKenney
2016-04-28 15:39 ` Akira Yokosawa
2016-04-28 16:28 ` Paul E. McKenney
2016-04-28 23:05 ` Akira Yokosawa
2016-04-29 16:00 ` Akira Yokosawa
2016-04-29 17:15 ` Paul E. McKenney
2016-04-29 22:06 ` Akira Yokosawa
2016-04-30 1:05 ` Paul E. McKenney
2012-01-27 13:12 Артём Алексюк
2010-11-09 20:31 connecting ieee80211_hw and net_device Zoltan Herczeg
2010-11-10 0:26 ` Johannes Berg
2010-11-11 14:20 ` Zoltan Herczeg
2010-11-12 22:33 ` Zoltan Herczeg
2010-11-16 17:50 ` some questions Zoltan Herczeg
2010-03-08 5:08 Some questions Tiago Maluta
2008-08-22 7:31 some questions Thomas Pasch
2008-08-22 8:53 ` Matthieu Moy
2008-08-22 14:08 ` Shawn O. Pearce
2008-08-22 9:28 ` Jakub Narebski
2008-08-22 14:15 ` Shawn O. Pearce
2008-05-04 16:16 David Arendt
[not found] ` <481DE17B.3080407-/LHdS3kC8BfYtjvyW6yDsg@public.gmane.org>
2008-05-05 15:55 ` Ryusuke Konishi
[not found] ` <20080506.005511.117028003.ryusuke-sG5X7nlA6pw@public.gmane.org>
2008-05-05 16:38 ` Ryusuke Konishi
2008-04-25 9:06 Some Questions James Scott
2008-04-26 7:48 ` Morten K. Poulsen
2008-04-27 9:47 ` James Scott
2003-03-05 12:18 Some questions Thomas Winischhofer
2003-03-05 13:26 ` Antonino Daplas
2003-03-05 14:06 ` Thomas Winischhofer
2003-03-05 15:25 ` Antonino Daplas
2003-03-05 15:37 ` Thomas Winischhofer
2003-03-05 15:44 ` Geert Uytterhoeven
2003-03-05 15:59 ` Thomas Winischhofer
2003-03-05 16:06 ` Geert Uytterhoeven
2003-03-05 16:34 ` Antonino Daplas
2003-03-05 16:06 ` Antonino Daplas
2003-03-05 16:17 ` Thomas Winischhofer
2003-03-05 16:44 ` Antonino Daplas
2003-03-05 17:01 ` Geert Uytterhoeven
2003-03-05 19:25 ` James Simmons
2003-03-05 19:27 ` James Simmons
2003-03-05 15:40 ` Geert Uytterhoeven
2003-03-05 15:54 ` Antonino Daplas
2003-03-05 19:31 ` James Simmons
2003-03-05 15:48 ` Antonino Daplas
2003-03-05 19:43 ` James Simmons
2003-03-05 22:21 ` Thomas Winischhofer
2003-03-06 0:18 ` James Simmons
2003-03-06 9:03 ` Thomas Winischhofer
2003-03-06 1:18 ` Antonino Daplas
2003-03-06 1:18 ` Antonino Daplas
2003-03-06 8:49 ` Thomas Winischhofer
2003-03-06 9:12 ` Geert Uytterhoeven
2003-03-06 9:58 ` Antonino Daplas
2003-03-06 10:14 ` Geert Uytterhoeven
2003-03-06 10:30 ` Antonino Daplas
2003-03-06 9:26 ` Antonino Daplas
2003-03-06 9:43 ` Thomas Winischhofer
2003-03-06 10:05 ` Antonino Daplas
2003-03-06 10:31 ` Sven Luther
2003-03-06 10:48 ` Antonino Daplas
2003-03-06 10:51 ` Antonino Daplas
2003-03-06 11:40 ` Sven Luther
2003-03-06 13:25 ` Antonino Daplas
2003-03-06 15:25 ` James Simmons
2003-03-06 15:27 ` James Simmons
2003-03-07 12:08 ` Thomas Winischhofer
2003-03-07 12:21 ` Geert Uytterhoeven
2003-03-07 18:19 ` James Simmons
2003-03-07 14:01 ` Antonino Daplas
2003-03-07 15:19 ` Thomas Winischhofer
2003-03-07 16:19 ` Antonino Daplas
2003-03-07 17:00 ` Thomas Winischhofer
2003-03-07 17:42 ` Antonino Daplas
2003-03-07 18:31 ` James Simmons
2003-03-07 17:49 ` Thomas Winischhofer
2003-03-11 16:23 ` James Simmons
2003-03-07 20:12 ` Antonino Daplas
2003-03-07 20:51 ` Thomas Winischhofer
2003-03-08 0:58 ` Antonino Daplas
2003-03-08 5:40 ` Antonino Daplas
2003-03-08 14:11 ` Thomas Winischhofer
2003-03-08 14:20 ` Thomas Winischhofer
2003-03-08 22:03 ` Antonino Daplas
2003-03-09 3:47 ` Thomas Winischhofer
2003-03-09 6:18 ` Antonino Daplas
2003-03-07 18:30 ` James Simmons
2003-03-11 16:07 ` James Simmons
2003-03-11 21:03 ` Thomas Winischhofer
2003-03-05 19:16 ` James Simmons
2003-03-05 19:30 ` Geert Uytterhoeven
2003-03-05 19:34 ` James Simmons
2003-03-05 22:13 ` Thomas Winischhofer
2003-03-05 23:53 ` James Simmons
2003-03-06 8:33 ` Geert Uytterhoeven
2003-03-06 9:00 ` Sven Luther
2003-03-06 9:03 ` Antonino Daplas
2003-03-11 16:29 ` James Simmons
2003-03-11 20:07 ` Antonino Daplas
2003-03-11 20:56 ` Thomas Winischhofer
2003-03-11 21:45 ` Antonino Daplas
2003-03-11 22:23 ` Thomas Winischhofer
2003-03-11 22:51 ` Antonino Daplas
2003-03-12 0:07 ` Michel Dänzer
2003-03-12 1:02 ` Antonino Daplas
2003-03-12 1:29 ` Michel Dänzer
2003-03-12 8:24 ` Geert Uytterhoeven
2003-03-12 15:56 ` Michel Dänzer
2003-03-11 22:27 ` Thomas Winischhofer
2003-03-11 22:51 ` Antonino Daplas
2003-03-11 23:12 ` Thomas Winischhofer
2003-03-05 14:12 ` Geert Uytterhoeven
2003-03-05 14:18 ` Thomas Winischhofer
2003-03-05 14:16 ` Thomas Winischhofer
2003-03-05 15:25 ` Antonino Daplas
2003-03-05 14:22 ` Thomas Winischhofer
2003-03-05 19:02 ` James Simmons
2003-03-06 1:18 ` Antonino Daplas
2003-03-05 18:57 ` James Simmons
2001-10-05 12:50 Justin R. Smith
2001-10-05 13:57 ` Stephen Smalley
2001-10-05 16:36 ` Paul Krumviede
1998-06-05 22:34 Alex deVries
1998-06-06 0:25 ` Ariel Faigon
1998-06-06 0:25 ` Ariel Faigon
1998-06-06 6:32 ` Peter Maydell
1998-06-06 15:36 ` Jeremy John Welling
1998-06-08 6:14 ` ralf
1998-06-09 0:17 ` Steve Rikli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-106132906900805@msgid-missing \
--to=joerg@alea.gnuu.de \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.