]> granicus.if.org Git - zfs/commitdiff
Add `cut` binary to the initramfs
authorBen Cordero <bencord0@condi.me>
Thu, 13 Dec 2018 23:48:46 +0000 (23:48 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 13 Dec 2018 23:48:46 +0000 (15:48 -0800)
Since the `cut -b` command is used by `parse-zfs.sh`,
ensure that it is copied to the initramfs.

Fix spl_hostid when set by cmdline. This follows a
similar logic from the `zgenhostid` script, using `echo`
instead of `printf`.

Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ben Cordero <bencord0@condi.me>
Closes #8197

contrib/dracut/90zfs/module-setup.sh.in
contrib/dracut/90zfs/parse-zfs.sh.in

index 38dd84d5a7630a5a2e3160ba046f0f796795574a..f595a369cd3ec5018d68908199fd51b5ddc45250 100755 (executable)
@@ -59,6 +59,7 @@ install() {
        dracut_install @udevdir@/vdev_id
        dracut_install awk
        dracut_install basename
+       dracut_install cut
        dracut_install head
        dracut_install @udevdir@/zvol_id
        inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
@@ -86,7 +87,7 @@ install() {
        BB=`hostid | cut -b 3,4`
        CC=`hostid | cut -b 5,6`
        DD=`hostid | cut -b 7,8`
-       printf "\x${DD}\x${CC}\x${BB}\x${AA}" > "${initdir}/etc/hostid"
+       echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" > "${initdir}/etc/hostid"
 
        if dracut_module_included "systemd"; then
                mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"
index 2a532c75b11216c267fb8c497df4e0d10b5f7587..eccfdc6bcbd1b40fe511463f7907a09d910f7b74 100755 (executable)
@@ -10,7 +10,7 @@ if [ -n "${spl_hostid}" ] ; then
        BB=$(echo "${spl_hostid}" | cut -b 3,4)
        CC=$(echo "${spl_hostid}" | cut -b 5,6)
        DD=$(echo "${spl_hostid}" | cut -b 7,8)
-       printf "\\x%s\\x%s\\x%s\\x%s" "${DD}" "${CC}" "${BB}" "${AA}" >/etc/hostid
+       echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" >/etc/hostid
 elif [ -f "/etc/hostid" ] ; then
        info "ZFS: Using hostid from /etc/hostid: $(hostid)"
 else