aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2007-08-29 18:46:34 +0000
committerBill Nottingham <notting@redhat.com>2007-08-29 18:46:34 +0000
commitbfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f (patch)
treeea6f8dcf0e89cffdc0b3005fee33e3f7e90f3101
parent65c11539f1724621a6cadcf96fb11894cce9f241 (diff)
downloadinitscripts-bfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f.tar
initscripts-bfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f.tar.gz
initscripts-bfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f.tar.bz2
initscripts-bfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f.tar.xz
initscripts-bfcdfb7fb5372264b7b78ddbfafdc9a3c2444e5f.zip
optimize out some excess greps (<harald@redhat.com>)
-rwxr-xr-xrc.d/init.d/functions12
-rwxr-xr-xrc.d/rc.sysinit6
2 files changed, 15 insertions, 3 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 528c050f..e85cff20 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -75,6 +75,18 @@ __readlink() {
ls -bl "$@" 2>/dev/null| awk '{ print $NF }'
}
+__fgrep() {
+ s=$1
+ f=$2
+ while read line; do
+ if strstr "$line" "$s"; then
+ echo $line
+ return 0
+ fi
+ done < $f
+ return 1
+}
+
# __umount_loop awk_program fstab_file first_msg retry_msg umount_args
# awk_program should process fstab_file and return a list of fstab-encoded
# paths; it doesn't have to handle comments in fstab_file.
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index 75705747..08adcc57 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -42,7 +42,7 @@ if [ -n "$selinuxfs" ] && [ "`cat /proc/self/attr/current`" != "kernel" ]; then
fi
fi
-if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts ; then
+if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then
/sbin/restorecon -R /dev 2>/dev/null
fi
@@ -414,7 +414,7 @@ if [ -f /etc/mdadm.conf ]; then
fi
# Device mapper & related initialization
-if ! LC_ALL=C fgrep -q "device-mapper" /proc/devices 2>/dev/null ; then
+if ! __fgrep "device-mapper" /proc/devices >/dev/null 2>&1 ; then
modprobe dm-mod >/dev/null 2>&1
fi
mkdir -p /dev/mapper >/dev/null 2>&1
@@ -444,7 +444,7 @@ if [ -c /dev/mapper/control ]; then
modprobe dm-mirror >/dev/null 2>&1
for x in $(/sbin/dmraid.static -ay -i -p -t 2>/dev/null | \
egrep -iv "^no " | \
- awk -F ':' '{ print $1 }') ; do
+ (IFS=":";while read a rest;do echo $a;done)) ; do
dmname=$(resolve_dm_name $x)
[ -z "$dmname" ] && continue
/sbin/dmraid.static -ay -i -p "$dmname" >/dev/null 2>&1