mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
cmd/zgenhostid: replace with simple c implementation
It was discovered that dracut scripts and zgenhostid always generate little-endian /etc/hostid. This commit provides simple endianess-aware binary and updates the scripts to use it. New features include: -f flag to force overwrite. -o flag to write to different file (for dracut) accepting both 0x01234567 and 01234567 values as input Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Olaf Faaland <faaland1@llnl.gov> Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> Closes #10887 Closes #10925
This commit is contained in:
@@ -5,7 +5,7 @@ check() {
|
||||
[ "${1}" = "-d" ] && return 0
|
||||
|
||||
# Verify the zfs tool chain
|
||||
for tool in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs" ; do
|
||||
for tool in "@bindir@/zgenhostid" "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs" ; do
|
||||
test -x "$tool" || return 1
|
||||
done
|
||||
# Verify grep exists
|
||||
@@ -38,6 +38,7 @@ install() {
|
||||
inst_rules @udevruledir@/60-zvol.rules
|
||||
dracut_install hostid
|
||||
dracut_install grep
|
||||
dracut_install @bindir@/zgenhostid
|
||||
dracut_install @sbindir@/zfs
|
||||
dracut_install @sbindir@/zpool
|
||||
# Workaround for zfsonlinux/zfs#4749 by ensuring libgcc_s.so(.1) is included
|
||||
@@ -83,11 +84,7 @@ install() {
|
||||
fi
|
||||
|
||||
# Synchronize initramfs and system hostid
|
||||
AA=`hostid | cut -b 1,2`
|
||||
BB=`hostid | cut -b 3,4`
|
||||
CC=`hostid | cut -b 5,6`
|
||||
DD=`hostid | cut -b 7,8`
|
||||
echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" > "${initdir}/etc/hostid"
|
||||
zgenhostid -o "${initdir}/etc/hostid" "$(hostid)"
|
||||
|
||||
if dracut_module_included "systemd"; then
|
||||
mkdir -p "${initdir}/$systemdsystemunitdir/zfs-import.target.wants"
|
||||
|
||||
@@ -6,11 +6,7 @@
|
||||
spl_hostid=$(getarg spl_hostid=)
|
||||
if [ -n "${spl_hostid}" ] ; then
|
||||
info "ZFS: Using hostid from command line: ${spl_hostid}"
|
||||
AA=$(echo "${spl_hostid}" | cut -b 1,2)
|
||||
BB=$(echo "${spl_hostid}" | cut -b 3,4)
|
||||
CC=$(echo "${spl_hostid}" | cut -b 5,6)
|
||||
DD=$(echo "${spl_hostid}" | cut -b 7,8)
|
||||
echo -ne "\\x${DD}\\x${CC}\\x${BB}\\x${AA}" >/etc/hostid
|
||||
zgenhostid -f "${spl_hostid}"
|
||||
elif [ -f "/etc/hostid" ] ; then
|
||||
info "ZFS: Using hostid from /etc/hostid: $(hostid)"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user