From: Seewer Philippe <philippe.seewer-omB+W0Dpw2o@public.gmane.org>
To: "<initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>"
<initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] Get rid of cat and grep
Date: Fri, 5 Jun 2009 13:56:23 +0200 [thread overview]
Message-ID: <4A2907E7.1080008@bfh.ch> (raw)
cat and grep just bloat the initrd, this patch removes dependencies on them.
---
modules.d/40network/ifup | 3 ++-
modules.d/40network/install | 2 +-
modules.d/40network/kill-dhclient.sh | 4 +++-
modules.d/95nbd/nbdroot | 12 +-----------
modules.d/95nfs/nfsroot | 12 ++----------
modules.d/95nfs/nfsroot-cleanup.sh | 2 +-
modules.d/99base/dracut-lib | 14 ++++++++++++++
7 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/modules.d/40network/ifup b/modules.d/40network/ifup
index 981a207..e347da5 100755
--- a/modules.d/40network/ifup
+++ b/modules.d/40network/ifup
@@ -100,7 +100,8 @@ if [ -z "$ip" ]; then
do_dhcp;
else
# spin through the kernel command line, looking for ip= lines
- for p in $(cat /proc/cmdline); do
+ [ "$CMDLINE" ] || read CMDLINE </proc/cmdline;
+ for p in $CMDLINE; do
[ -n "${p%ip=*}" ] && continue
ip_to_var ${p#ip=}
diff --git a/modules.d/40network/install b/modules.d/40network/install
index d480391..3a06f79 100755
--- a/modules.d/40network/install
+++ b/modules.d/40network/install
@@ -1,5 +1,5 @@
#!/bin/bash
-dracut_install ip dhclient hostname cat
+dracut_install ip dhclient hostname
# Include wired net drivers, excluding wireless
for modname in `find "/lib/modules/$kernel/kernel/drivers" -name '*.ko'`; do
if nm -uPA $modname | grep -q eth_type_trans; then
diff --git a/modules.d/40network/kill-dhclient.sh b/modules.d/40network/kill-dhclient.sh
index fcebd32..54b3344 100755
--- a/modules.d/40network/kill-dhclient.sh
+++ b/modules.d/40network/kill-dhclient.sh
@@ -1,5 +1,7 @@
#!/bin/sh
for f in /tmp/dhclient.*.pid; do
- [ -e $f ] && kill $(cat $f)
+ [ -e $f ] || continue
+ read PID < $f;
+ kill $PID;
done
diff --git a/modules.d/95nbd/nbdroot b/modules.d/95nbd/nbdroot
index 1130cca..3475239 100755
--- a/modules.d/95nbd/nbdroot
+++ b/modules.d/95nbd/nbdroot
@@ -71,17 +71,7 @@ getarg ro && nbdrw=ro
getarg rw && nbdrw=rw
fsopts=${fsopts+$fsopts,}${nbdrw}
-if [ ! -e /tmp/nbd.present ]; then
- cat /proc/devices | while read t1 devt; do
- if [ "$devt" = "nbd" ]; then
- >/tmp/nfs.present
- break
- fi
- done
-fi
-if [ ! -e /tmp/nbd.present ]; then
- modprobe nbd || exit 1
-fi
+incol2 /proc/devices nbd || modprobe nbd || exit 1
# XXX better way to wait for the device to be made?
i=0
diff --git a/modules.d/95nfs/nfsroot b/modules.d/95nfs/nfsroot
index 2d08b68..da002c5 100755
--- a/modules.d/95nfs/nfsroot
+++ b/modules.d/95nfs/nfsroot
@@ -46,16 +46,8 @@ getarg rw && nfsrw=rw
nfsflags=${nfsflags+$nfsflags,}${nfsrw}
# Load the modules so the filesystem type is there
-if [ ! -e /tmp/nfs.present ]; then
- cat /proc/filesystems | while read t1 fst; do
- case "$fst" in
- nfs|nfs4) >/tmp/nfs.present; break ;;
- esac
- done
-fi
-if [ ! -e /tmp/nfs.present ]; then
- modprobe nfs || exit 1
-fi
+incol2 /proc/filesystems nfs || modprobe nfs || exit 1
+incol2 /proc/filesystems nfs4 || modprobe nfs || exit 1
# XXX don't forget to move /var/lib/nfs/rpc_pipefs to new /
diff --git a/modules.d/95nfs/nfsroot-cleanup.sh b/modules.d/95nfs/nfsroot-cleanup.sh
index 4bfdd34..1a5f187 100644
--- a/modules.d/95nfs/nfsroot-cleanup.sh
+++ b/modules.d/95nfs/nfsroot-cleanup.sh
@@ -4,7 +4,7 @@ pid=$(pidof rpc.statd)
pid=$(pidof rpcbind)
[ -n "$pid" ] && kill $pid
-if grep -q rpc_pipefs /proc/mounts; then
+if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
# try to create the destination directory
[ -d $NEWROOT/var/lib/nfs/rpc_pipefs ] || mkdir -p $NEWROOT/var/lib/nfs/rpc_pipefs 2>/dev/null
diff --git a/modules.d/99base/dracut-lib b/modules.d/99base/dracut-lib
index e3f4794..07c1bc7 100644
--- a/modules.d/99base/dracut-lib
+++ b/modules.d/99base/dracut-lib
@@ -36,3 +36,17 @@ check_occurances() {
[ $count -eq $expected ]
}
+
+incol2() {
+ local dummy check;
+ local file="$1";
+ local str="$2";
+
+ [ -z "$file" ] && return;
+ [ -z "$str" ] && return;
+
+ while read dummy check ; do
+ [ "$check" = "$str" ] && return 0
+ done < $file
+ return 1
+}
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2009-06-05 11:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-05 11:56 Seewer Philippe [this message]
[not found] ` <4A2907E7.1080008-omB+W0Dpw2o@public.gmane.org>
2009-06-05 13:39 ` [PATCH] Get rid of cat and grep Harald Hoyer
[not found] ` <4A292005.4000404-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-05 13:40 ` Seewer Philippe
2009-06-05 14:43 ` David Dillow
[not found] ` <1244213032.6963.1.camel-FqX9LgGZnHWDB2HL1qBt2PIbXMQ5te18@public.gmane.org>
2009-06-05 14:59 ` Harald Hoyer
2009-06-05 15:58 ` Bill Nottingham
[not found] ` <20090605155832.GH5107-Zdt1ptygihhQcNjhGXsBABcY2uh10dtjAL8bYrjMMd8@public.gmane.org>
2009-06-05 16:03 ` Warren Togami
[not found] ` <4A2941CD.1070709-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-05 18:11 ` Seewer Philippe
[not found] ` <4A295FB4.6020306-omB+W0Dpw2o@public.gmane.org>
2009-06-05 18:21 ` Dave Jones
[not found] ` <20090605182106.GA26921-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2009-06-05 18:23 ` Warren Togami
2009-06-05 18:37 ` David Dillow
[not found] ` <1244227068.6963.37.camel-FqX9LgGZnHWDB2HL1qBt2PIbXMQ5te18@public.gmane.org>
2009-06-05 18:45 ` Victor Lowther
[not found] ` <759A4D42-1B71-438B-A361-4CFCB6E289E7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-06-05 18:57 ` David Dillow
2009-06-05 19:37 ` Seewer Philippe
2009-06-05 16:16 ` Victor Lowther
[not found] ` <E0B0F7E0-7880-4219-AE91-B7305665424D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-06-05 16:38 ` Bill Nottingham
[not found] ` <20090605163828.GA7041-Zdt1ptygihhQcNjhGXsBABcY2uh10dtjAL8bYrjMMd8@public.gmane.org>
2009-06-05 16:46 ` Harald Hoyer
2009-06-05 16:51 ` David Dillow
2009-06-05 16:20 ` Victor Lowther
[not found] ` <8E821C8B-E7E8-4F71-ACCF-872B463AE3FF-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-06-05 16:49 ` David Dillow
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=4A2907E7.1080008@bfh.ch \
--to=philippe.seewer-omb+w0dpw2o@public.gmane.org \
--cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox