update to latest git

This commit is contained in:
Harald Hoyer 2012-02-17 12:39:11 +01:00
parent c0b9038711
commit 0359152804
9 changed files with 879 additions and 1 deletions

View File

@ -0,0 +1,24 @@
From a2c631c0a3d3208069ebccefc39f591e0595a545 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Feb 2012 09:36:13 +0100
Subject: [PATCH] Makefile: also link dracut-shutdown.service to shutdown
target
---
Makefile | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 321e923..6556c01 100644
--- a/Makefile
+++ b/Makefile
@@ -52,7 +52,9 @@ install: doc
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \
+ mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \
ln -s ../dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants/dracut-shutdown.service; \
+ ln -s ../dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
fi
clean:

View File

@ -0,0 +1,40 @@
From 75cade1216b62957efad7e97c77e4e8b0414a515 Mon Sep 17 00:00:00 2001
From: Dave Young <dyoung@redhat.com>
Date: Thu, 16 Feb 2012 09:36:29 +0800
Subject: [PATCH] add function wait_for_route_ok
Manually setuping nic through udev is not always done when
we want network access. Here add a function wait_for_route_ok to
wait and make sure the network is accesible
[v1 -> v2]:
Harald: don't use bash syntax
Add check for [ -n "$li" ] because `ip route show` will show nothing probably
Signed-off-by: Dave Young <dyoung@redhat.com>
---
modules.d/99base/dracut-lib.sh | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 6b70adf..afd366e 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -392,6 +392,17 @@ wait_for_if_up() {
return 1
}
+wait_for_route_ok() {
+ local cnt=0
+ while [ $cnt -lt 200 ]; do
+ li=$(ip route show)
+ [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
+ sleep 0.1
+ cnt=$(($cnt+1))
+ done
+ return 1
+}
+
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {

View File

@ -0,0 +1,27 @@
From c1df00d2c62f9cd79957d62dda025964108f12de Mon Sep 17 00:00:00 2001
From: Will Woods <wwoods@redhat.com>
Date: Wed, 15 Feb 2012 13:36:09 -0500
Subject: [PATCH] livenet: avoid spurious error message / wait_for_dev
If the user didn't request a livenet boot, don't print an error
and don't do wait_for_dev.
Signed-off-by: Will Woods <wwoods@redhat.com>
---
modules.d/90livenet/parse-livenet.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/modules.d/90livenet/parse-livenet.sh b/modules.d/90livenet/parse-livenet.sh
index 042cc51..926dba2 100755
--- a/modules.d/90livenet/parse-livenet.sh
+++ b/modules.d/90livenet/parse-livenet.sh
@@ -15,8 +15,7 @@ if get_url_handler "$liveurl" >/dev/null; then
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1
+ wait_for_dev /dev/root
else
info "livenet: no url handler for $liveurl"
fi
-
-wait_for_dev /dev/root

View File

@ -0,0 +1,33 @@
From 86de902e35a7c57ecc008ba725b7842e36bf7393 Mon Sep 17 00:00:00 2001
From: Dave Young <dyoung@redhat.com>
Date: Wed, 15 Feb 2012 14:40:24 +0800
Subject: [PATCH] ssh-client module install fix
commit 38164332e198f7cc8f339b42d555796918de04b3 try to
disallow ssh-client install for without proper options.
But ssh-client will fail installation with --sshkey for
publickey mode
Fix it by refusing to install only when both --ctty and --sshkey
are not added in options.
Signed-off-by: Dave Young <dyoung@redhat.com>
---
modules.d/95ssh-client/module-setup.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules.d/95ssh-client/module-setup.sh b/modules.d/95ssh-client/module-setup.sh
index 4410e4e..8d62b2d 100755
--- a/modules.d/95ssh-client/module-setup.sh
+++ b/modules.d/95ssh-client/module-setup.sh
@@ -50,8 +50,8 @@ inst_sshenv()
}
install() {
- [[ ! $cttyhack = yes ]] && {
- derror "ssh interactive mode needs option --ctty!"
+ [[ ! $cttyhack = yes && ! $sshkey ]] && {
+ derror "ssh-client needs option --ctty or --sshkey!"
return 1
}

View File

@ -0,0 +1,40 @@
From 2a3faa2df9ba46ff7759c2201e8ec7056e84d6de Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Feb 2012 11:34:37 +0100
Subject: [PATCH] 95iscsi: fix "root=iscsi:...." case
install udev rules and wait for /dev/root
---
modules.d/95iscsi/iscsiroot | 1 +
modules.d/95iscsi/parse-iscsiroot.sh | 4 +++-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/modules.d/95iscsi/iscsiroot b/modules.d/95iscsi/iscsiroot
index d8f7c8f..7b8f63e 100755
--- a/modules.d/95iscsi/iscsiroot
+++ b/modules.d/95iscsi/iscsiroot
@@ -46,6 +46,7 @@ if getargbool 0 rd.iscsi.firmware -y iscsi_firmware ; then
if [ -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
+ udevadm control --reload
fi
iscsistart -b
exit 0
diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
index 40720e8..64aae84 100755
--- a/modules.d/95iscsi/parse-iscsiroot.sh
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
@@ -28,9 +28,11 @@
if [ "${root%%:*}" = "iscsi" ] ; then
if [ -n "$netroot" ] ; then
echo "Warning: root takes precedence over netroot. Ignoring netroot"
-
fi
netroot=$root
+ # if root is not specified try to mount the whole iSCSI LUN
+ printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
+ root=/dev/root
fi
# If it's not empty or iscsi we don't continue

View File

@ -0,0 +1,333 @@
From 3905f6695ebbc8666c37d585bb5e7093d43ab8ac Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Feb 2012 11:37:21 +0100
Subject: [PATCH] TEST-30-ISCSI: add test case for "root=iscsi:...." and
untabify
---
test/TEST-30-ISCSI/test.sh | 227 +++++++++++++++++++++++--------------------
1 files changed, 121 insertions(+), 106 deletions(-)
diff --git a/test/TEST-30-ISCSI/test.sh b/test/TEST-30-ISCSI/test.sh
index 667c6a9..7899f76 100755
--- a/test/TEST-30-ISCSI/test.sh
+++ b/test/TEST-30-ISCSI/test.sh
@@ -12,18 +12,18 @@ run_server() {
echo "iSCSI TEST SETUP: Starting DHCP/iSCSI server"
$testdir/run-qemu \
- -hda $TESTDIR/server.ext2 \
- -hdb $TESTDIR/root.ext2 \
- -hdc $TESTDIR/iscsidisk2.img \
- -hdd $TESTDIR/iscsidisk3.img \
- -m 256M -nographic \
- -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
- -net socket,listen=127.0.0.1:12330 \
- -serial $SERIAL \
- -kernel /boot/vmlinuz-$KVERSION \
- -append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.server \
- -pidfile $TESTDIR/server.pid -daemonize || return 1
+ -hda $TESTDIR/server.ext2 \
+ -hdb $TESTDIR/root.ext2 \
+ -hdc $TESTDIR/iscsidisk2.img \
+ -hdd $TESTDIR/iscsidisk3.img \
+ -m 256M -nographic \
+ -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
+ -net socket,listen=127.0.0.1:12330 \
+ -serial $SERIAL \
+ -kernel /boot/vmlinuz-$KVERSION \
+ -append "root=/dev/sda rw quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.server \
+ -pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
@@ -37,55 +37,70 @@ run_client() {
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
- echo "Unable to make client sda image" 1>&2
- return 1
+ echo "Unable to make client sda image" 1>&2
+ return 1
fi
$testdir/run-qemu \
- -hda $TESTDIR/client.img \
- -m 256M -nographic \
- -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
- -net socket,connect=127.0.0.1:12330 \
- -kernel /boot/vmlinuz-$KVERSION \
- -append "root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:eth0:off netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2 rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
- -initrd $TESTDIR/initramfs.testing
+ -hda $TESTDIR/client.img \
+ -m 256M -nographic \
+ -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
+ -net socket,connect=127.0.0.1:12330 \
+ -kernel /boot/vmlinuz-$KVERSION \
+ -append "root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0 ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:eth0:off rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+ -initrd $TESTDIR/initramfs.testing
grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
- echo "Unable to make client sda image" 1>&2
- return 1
+ echo "Unable to make client sda image" 1>&2
+ return 1
fi
$testdir/run-qemu \
- -hda $TESTDIR/client.img \
- -m 256M -nographic \
- -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
- -net socket,connect=127.0.0.1:12330 \
- -kernel /boot/vmlinuz-$KVERSION \
- -append "root=dhcp rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
- -initrd $TESTDIR/initramfs.testing
+ -hda $TESTDIR/client.img \
+ -m 256M -nographic \
+ -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
+ -net socket,connect=127.0.0.1:12330 \
+ -kernel /boot/vmlinuz-$KVERSION \
+ -append "root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:eth0:off netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2 rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+ -initrd $TESTDIR/initramfs.testing
+ grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1
+
+ if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
+ echo "Unable to make client sda image" 1>&2
+ return 1
+ fi
+
+ $testdir/run-qemu \
+ -hda $TESTDIR/client.img \
+ -m 256M -nographic \
+ -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
+ -net socket,connect=127.0.0.1:12330 \
+ -kernel /boot/vmlinuz-$KVERSION \
+ -append "root=dhcp rw quiet rd.retry=5 rd.debug rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
+ -initrd $TESTDIR/initramfs.testing
grep -m 1 -q iscsi-OK $TESTDIR/client.img || return 1
}
test_run() {
if ! run_server; then
- echo "Failed to start server" 1>&2
- return 1
+ echo "Failed to start server" 1>&2
+ return 1
fi
run_client
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
- sudo kill -TERM $(cat $TESTDIR/server.pid)
- rm -f $TESTDIR/server.pid
+ sudo kill -TERM $(cat $TESTDIR/server.pid)
+ rm -f $TESTDIR/server.pid
fi
return $ret
}
test_setup() {
if [ ! -x /usr/sbin/iscsi-target ]; then
- echo "Need iscsi-target from netbsd-iscsi"
- return 1
+ echo "Need iscsi-target from netbsd-iscsi"
+ return 1
fi
# Create the blank file to use as a root filesystem
@@ -96,68 +111,68 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
- initdir=$TESTDIR/overlay/source
- . $basedir/dracut-functions
- dracut_install sh shutdown poweroff stty cat ps ln ip \
+ initdir=$TESTDIR/overlay/source
+ . $basedir/dracut-functions
+ dracut_install sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
- [ -f ${_terminfodir}/l/linux ] && break
- done
- dracut_install -o ${_terminfodir}/l/linux
- inst ./client-init /sbin/init
- (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
- cp -a /etc/ld.so.conf* $initdir/etc
- sudo ldconfig -r "$initdir"
+ [ -f ${_terminfodir}/l/linux ] && break
+ done
+ dracut_install -o ${_terminfodir}/l/linux
+ inst ./client-init /sbin/init
+ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
+ cp -a /etc/ld.so.conf* $initdir/etc
+ sudo ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
(
- initdir=$TESTDIR/overlay
- . $basedir/dracut-functions
- dracut_install sfdisk mke2fs poweroff cp umount
- inst_hook initqueue 01 ./create-root.sh
- inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+ initdir=$TESTDIR/overlay
+ . $basedir/dracut-functions
+ dracut_install sfdisk mke2fs poweroff cp umount
+ inst_hook initqueue 01 ./create-root.sh
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i $TESTDIR/overlay / \
- -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ -m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/null of=$TESTDIR/client.img bs=1M seek=1; then
- echo "Unable to make client sdb image" 1>&2
- return 1
+ echo "Unable to make client sdb image" 1>&2
+ return 1
fi
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
- -hda $TESTDIR/root.ext2 \
- -hdb $TESTDIR/client.img \
- -hdc $TESTDIR/iscsidisk2.img \
- -hdd $TESTDIR/iscsidisk3.img \
- -m 256M -nographic -net none \
- -kernel "/boot/vmlinuz-$kernel" \
- -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
- -initrd $TESTDIR/initramfs.makeroot || return 1
+ -hda $TESTDIR/root.ext2 \
+ -hdb $TESTDIR/client.img \
+ -hdc $TESTDIR/iscsidisk2.img \
+ -hdd $TESTDIR/iscsidisk3.img \
+ -m 256M -nographic -net none \
+ -kernel "/boot/vmlinuz-$kernel" \
+ -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm $TESTDIR/client.img
(
- initdir=$TESTDIR/overlay
- . $basedir/dracut-functions
- dracut_install poweroff shutdown
- inst_hook emergency 000 ./hard-off.sh
- inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+ initdir=$TESTDIR/overlay
+ . $basedir/dracut-functions
+ dracut_install poweroff shutdown
+ inst_hook emergency 000 ./hard-off.sh
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut -l -i $TESTDIR/overlay / \
- -o "plymouth dmraid" \
- -a "debug" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
- -f $TESTDIR/initramfs.testing $KVERSION || return 1
+ -o "plymouth dmraid" \
+ -a "debug" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
# Make server root
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60
@@ -167,36 +182,36 @@ test_setup() {
kernel=$KVERSION
(
- initdir=$TESTDIR/mnt
- . $basedir/dracut-functions
- (
- cd "$initdir";
- mkdir -p dev sys proc etc var/run tmp var/lib/dhcpd /etc/iscsi
- )
- inst /etc/passwd /etc/passwd
- dracut_install sh ls shutdown poweroff stty cat ps ln ip \
- dmesg mkdir cp ping \
- modprobe tcpdump \
- /etc/services sleep mount chmod
- dracut_install /usr/sbin/iscsi-target
+ initdir=$TESTDIR/mnt
+ . $basedir/dracut-functions
+ (
+ cd "$initdir";
+ mkdir -p dev sys proc etc var/run tmp var/lib/dhcpd /etc/iscsi
+ )
+ inst /etc/passwd /etc/passwd
+ dracut_install sh ls shutdown poweroff stty cat ps ln ip \
+ dmesg mkdir cp ping \
+ modprobe tcpdump \
+ /etc/services sleep mount chmod
+ dracut_install /usr/sbin/iscsi-target
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
- [ -f ${_terminfodir}/l/linux ] && break
- done
- dracut_install -o ${_terminfodir}/l/linux
- instmods iscsi_tcp crc32c ipv6
+ [ -f ${_terminfodir}/l/linux ] && break
+ done
+ dracut_install -o ${_terminfodir}/l/linux
+ instmods iscsi_tcp crc32c ipv6
inst ./targets /etc/iscsi/targets
- [ -f /etc/netconfig ] && dracut_install /etc/netconfig
- type -P dhcpd >/dev/null && dracut_install dhcpd
- [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
- inst ./server-init /sbin/init
- inst ./hosts /etc/hosts
- inst ./dhcpd.conf /etc/dhcpd.conf
- dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols
- inst /etc/group /etc/group
-
- /sbin/depmod -a -b "$initdir" $kernel
- cp -a /etc/ld.so.conf* $initdir/etc
- sudo ldconfig -r "$initdir"
+ [ -f /etc/netconfig ] && dracut_install /etc/netconfig
+ type -P dhcpd >/dev/null && dracut_install dhcpd
+ [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
+ inst ./server-init /sbin/init
+ inst ./hosts /etc/hosts
+ inst ./dhcpd.conf /etc/dhcpd.conf
+ dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols
+ inst /etc/group /etc/group
+
+ /sbin/depmod -a -b "$initdir" $kernel
+ cp -a /etc/ld.so.conf* $initdir/etc
+ sudo ldconfig -r "$initdir"
)
sudo umount $TESTDIR/mnt
@@ -204,16 +219,16 @@ test_setup() {
# Make server's dracut image
$basedir/dracut -l -i $TESTDIR/overlay / \
- -m "dash udev-rules base rootfs-block debug kernel-modules" \
- -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \
- -f $TESTDIR/initramfs.server $KVERSION || return 1
+ -m "dash udev-rules base rootfs-block debug kernel-modules" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod e1000" \
+ -f $TESTDIR/initramfs.server $KVERSION || return 1
}
test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
- sudo kill -TERM $(cat $TESTDIR/server.pid)
- rm -f $TESTDIR/server.pid
+ sudo kill -TERM $(cat $TESTDIR/server.pid)
+ rm -f $TESTDIR/server.pid
fi
}

View File

@ -0,0 +1,56 @@
From c4e48eaea1b31a8c70af43a400eda7948cfecc94 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Feb 2012 11:48:17 +0100
Subject: [PATCH] dracut-functions: factor out all get_maj_min() variants
---
dracut-functions | 15 +++------------
1 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index 41d752e..0b24889 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -212,11 +212,7 @@ find_block_device() {
[[ $_dev != ${_dev#UUID=} ]] && _dev=/dev/disk/by-uuid/${_dev#UUID=}
[[ $_dev != ${_dev#LABEL=} ]] && _dev=/dev/disk/by-label/${_dev#LABEL=}
[[ -b $_dev ]] || return 1 # oops, not a block device.
- ls -nLl "$_dev" | {
- read _x _x _x _x _maj _min _x
- _maj=${_maj//,/}
- echo $_maj:$_min
- } && return 0
+ get_maj_min "$_dev" && return 0
fi
done < /etc/fstab
@@ -281,11 +277,6 @@ check_block_and_slaves() {
return 1
}
-get_numeric_dev() {
- local _x _maj _min
- ls -lH "$1" | { read _x _x _x _x _maj _min _x; printf "%d:%d" ${_maj%%,} $_min; }
-}
-
# ugly workaround for the lvm design
# There is no volume group device,
# so, there are no slave devices for volume groups.
@@ -295,7 +286,7 @@ get_numeric_dev() {
check_vol_slaves() {
local _lv _vg _pv
for i in /dev/mapper/*; do
- _lv=$(get_numeric_dev $i)
+ _lv=$(get_maj_min $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
@@ -303,7 +294,7 @@ check_vol_slaves() {
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
- check_block_and_slaves $1 $(get_numeric_dev $_pv) && return 0
+ check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
done
fi
fi

View File

@ -0,0 +1,314 @@
From 7e2bca48208413b940ebdf875c718a0d08e490ac Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Feb 2012 11:49:19 +0100
Subject: [PATCH] dracut-functions: documentation and restructuring
---
dracut-functions | 157 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 122 insertions(+), 35 deletions(-)
diff --git a/dracut-functions b/dracut-functions
index 0b24889..e0a08ab 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -32,6 +32,13 @@ if ! type dinfo >/dev/null 2>&1; then
dlog_init
fi
+# export standard hookdirs
+[[ $hookdirs ]] || {
+ hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
+ hookdirs+=" pre-pivot mount emergency shutdown-emergency shutdown cleanup"
+ export hookdirs
+}
+
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 =~ $2 ]]; }
@@ -66,6 +73,8 @@ vercmp() {
esac
}
+# is_func <command>
+# Check whether $1 is a function.
is_func() {
[[ $(type -t $1) = "function" ]]
}
@@ -82,6 +91,12 @@ print_vars() {
done
}
+# normalize_path <path>
+# Prints the normalized path, where it removes any duplicated
+# and trailing slashes.
+# Example:
+# $ normalize_path ///test/test//
+# /test/test
normalize_path() {
shopt -q -s extglob
set -- "${1//+(\/)//}"
@@ -89,10 +104,15 @@ normalize_path() {
echo "${1%/}"
}
+# convert_abs_rel <from> <to>
+# Prints the relative path, when creating a symlink to <to> from <from>.
+# Example:
+# $ convert_abs_rel /usr/bin/test /bin/test-2
+# ../../bin/test-2
+# $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
convert_abs_rel() {
local __current __absolute __abssize __cursize __newpath __oldifs
local -i __i __level
-# PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
@@ -141,6 +161,12 @@ convert_abs_rel() {
echo "$__newpath"
}
+# get_fs_env <device>
+# Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device.
+# Example:
+# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE; echo $ID_FS_UUID
+# ext4
+# 551a39aa-4ae9-4e70-a262-ef665cadb574
get_fs_env() {
[[ $1 ]] || return
unset ID_FS_TYPE
@@ -157,6 +183,21 @@ get_fs_env() {
fi
}
+# get_fs_uuid <device>
+# Prints the filesystem UUID for a device.
+# Example:
+# $ get_fs_uuid /dev/sda2
+# 551a39aa-4ae9-4e70-a262-ef665cadb574
+get_fs_uuid() (
+ get_fs_env $1 || return
+ echo $ID_FS_UUID
+)
+
+# get_fs_type <device>
+# Prints the filesystem type for a device.
+# Example:
+# $ get_fs_type /dev/sda1
+# ext4
get_fs_type() (
[[ $1 ]] || return
if [[ $1 != ${1#/dev/block/nfs:} ]] \
@@ -172,12 +213,11 @@ get_fs_type() (
find_dev_fstype $1
)
-get_fs_uuid() (
- get_fs_env $1 || return
- echo $ID_FS_UUID
-)
-
-
+# get_maj_min <device>
+# Prints the major and minor of a device node.
+# Example:
+# $ get_maj_min /dev/sda2
+# 8:2
get_maj_min() {
local _dev
_dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null)
@@ -185,6 +225,16 @@ get_maj_min() {
echo $_dev
}
+# find_block_device <mountpoint>
+# Prints the major and minor number of the block device
+# for a given mountpoint.
+# Unless $use_fstab is set to "yes" the functions
+# uses /proc/self/mountinfo as the primary source of the
+# information and only falls back to /etc/fstab, if the mountpoint
+# is not found there.
+# Example:
+# $ find_block_device /usr
+# 8:4
find_block_device() {
local _x _mpt _majmin _dev _fs _maj _min
if [[ $use_fstab != yes ]]; then
@@ -219,6 +269,14 @@ find_block_device() {
return 1
}
+# find_dev_fstype <device>
+# Echo the filesystem type for a given device.
+# /proc/self/mountinfo is taken as the primary source of information
+# and /etc/fstab is used as a fallback.
+# No newline is appended!
+# Example:
+# $ find_dev_fstype /dev/sda2;echo
+# ext4
find_dev_fstype() {
local _x _mpt _majmin _dev _fs _maj _min
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
@@ -240,6 +298,9 @@ find_dev_fstype() {
# finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; }
+# for_each_host_dev_fs <func>
+# Execute "<func> <dev> <filesystem>" for every "<dev>|<fs>" pair found
+# in ${host_fs_types[@]}
for_each_host_dev_fs()
{
local _func="$1"
@@ -581,12 +642,6 @@ inst() {
return 1
}
-[[ $hookdirs ]] || {
- hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
- hookdirs+=" pre-pivot mount emergency shutdown-emergency shutdown cleanup"
- export hookdirs
-}
-
# install function specialized for hooks
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
# All hooks should be POSIX/SuS compliant, they will be sourced by init.
@@ -630,6 +685,9 @@ inst_any() {
return 1
}
+# dracut_install [-o ] <file> [<file> ... ]
+# Install <file> to the initramfs image
+# -o optionally install the <file> and don't fail, if it is not there
dracut_install() {
local _optional=no
if [[ $1 = '-o' ]]; then
@@ -697,6 +755,10 @@ inst_opt_decompress() {
done
}
+# module_check <dracut module>
+# execute the check() function of module-setup.sh of <dracut module>
+# or the "check" script, if module-setup.sh is not found
+# "check $hostonly" is called
module_check() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -723,6 +785,35 @@ module_check() {
return $_ret
}
+# module_check_mount <dracut module>
+# execute the check() function of module-setup.sh of <dracut module>
+# or the "check" script, if module-setup.sh is not found
+# "mount_needs=1 check 0" is called
+module_check_mount() {
+ local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
+ local _ret
+ mount_needs=1
+ [[ -d $_moddir ]] || return 1
+ if [[ ! -f $_moddir/module-setup.sh ]]; then
+ # if we do not have a check script, we are unconditionally included
+ [[ -x $_moddir/check ]] || return 0
+ mount_needs=1 $_moddir/check 0
+ _ret=$?
+ else
+ unset check depends install installkernel
+ . $_moddir/module-setup.sh
+ is_func check || return 1
+ check 0
+ _ret=$?
+ unset check depends install installkernel
+ fi
+ unset mount_needs
+ return $_ret
+}
+
+# module_depends <dracut module>
+# execute the depends() function of module-setup.sh of <dracut module>
+# or the "depends" script, if module-setup.sh is not found
module_depends() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -743,6 +834,9 @@ module_depends() {
fi
}
+# module_install <dracut module>
+# execute the install() function of module-setup.sh of <dracut module>
+# or the "install" script, if module-setup.sh is not found
module_install() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -761,6 +855,9 @@ module_install() {
fi
}
+# module_installkernel <dracut module>
+# execute the installkernel() function of module-setup.sh of <dracut module>
+# or the "installkernel" script, if module-setup.sh is not found
module_installkernel() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -779,28 +876,9 @@ module_installkernel() {
fi
}
-module_check_mount() {
- local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
- local _ret
- mount_needs=1
- [[ -d $_moddir ]] || return 1
- if [[ ! -f $_moddir/module-setup.sh ]]; then
- # if we do not have a check script, we are unconditionally included
- [[ -x $_moddir/check ]] || return 0
- mount_needs=1 $_moddir/check 0
- _ret=$?
- else
- unset check depends install installkernel
- . $_moddir/module-setup.sh
- is_func check || return 1
- check 0
- _ret=$?
- unset check depends install installkernel
- fi
- unset mount_needs
- return $_ret
-}
-
+# check_mount <dracut module>
+# check_mount checks, if a dracut module is needed for the given
+# device and filesystem types in "${host_fs_types[@]}"
check_mount() {
local _mod=$1
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
@@ -840,6 +918,10 @@ check_mount() {
return 0
}
+# check_module <dracut module> [<use_as_dep>]
+# check if a dracut module is to be used in the initramfs process
+# if <use_as_dep> is set, then the process also keeps track
+# that the modules were checked for the dependency tracking process
check_module() {
local _mod=$1
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
@@ -891,6 +973,8 @@ check_module() {
return 0
}
+# for_each_module_dir <func>
+# execute "<func> <dracut module> 1"
for_each_module_dir() {
local _modcheck
local _mod
@@ -1028,7 +1112,10 @@ find_kernel_modules () {
find_kernel_modules_by_path drivers
}
+# instmods <kernel module> [<kernel module> ... ]
+# instmods <kernel subsystem>
# install kernel modules along with all their dependencies.
+# <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
instmods() {
[[ $no_kernel = yes ]] && return
# called [sub]functions inherit _fderr

View File

@ -10,7 +10,7 @@
Name: dracut
Version: 016
Release: 1%{?dist}
Release: 9.git20120217%{?dist}
Summary: Initramfs generator using udev
%if 0%{?fedora} || 0%{?rhel} > 6
@ -24,6 +24,14 @@ URL: https://dracut.wiki.kernel.org/
# Source can be generated by
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
Patch1: 0001-Makefile-also-link-dracut-shutdown.service-to-shutdo.patch
Patch2: 0002-add-function-wait_for_route_ok.patch
Patch3: 0003-livenet-avoid-spurious-error-message-wait_for_dev.patch
Patch4: 0004-ssh-client-module-install-fix.patch
Patch5: 0005-95iscsi-fix-root-iscsi-.-case.patch
Patch6: 0006-TEST-30-ISCSI-add-test-case-for-root-iscsi-.-and-unt.patch
Patch7: 0007-dracut-functions-factor-out-all-get_maj_min-variants.patch
Patch8: 0008-dracut-functions-documentation-and-restructuring.patch
BuildArch: noarch
@ -320,6 +328,9 @@ rm -rf $RPM_BUILD_ROOT
%dir /var/lib/dracut/overlay
%changelog
* Fri Feb 17 2012 Harald Hoyer <harald@redhat.com> 016-9.git20120217
- update to latest git
* Wed Feb 15 2012 Harald Hoyer <harald@redhat.com> 016-1
- version 016