Record hostid into initramfs

ZFS pool import on non-exported pools is only permitted when the hostid
of the system matches the host id of the last pool to import it. Store
the hostid of the system to ensure that it matches at boot.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Create rootfs_type_is() helper function

This is meant to facilite automatic detection of root filesystems that
require additional support. The main one being ZFS, but btrfs will also
qualify once support has been added.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Include ZFS support when / is ZFS

Signed-off-by: Richard Yao <ryao@gentoo.org>
Advertise zfs support in genkernel.conf

Signed-off-by: Martin Dummer <martin.dummer@gmx.net>
Signed-off-by: Richard Yao <ryao@gentoo.org>
fix broken function prompt_user()

There is a mistake in the parameter check of function prompt_user()
which causes to exit the initramfs unconditionally when the function is
called with *correct* number of parameters (which then causes a kernel
panic)
This patch puts the parameter check into a readable if..then..fi block.

Signed-off-by: Martin Dummer <martin.dummer@gmx.net>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Fix endless loop in gen_funcs.sh when LOGLEVEL is empty

When LOGLEVEL is unset or empty then genkernel loops endlessly in
gen_funcs.sh.
The solution is to set a proper default loglevel in $USRBIN/genkernel.

Signed-off-by: Martin Dummer <martin.dummer@gmx.net>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Try mmap() when loading modules

Signed-off-by: Richard Yao <ryao@gentoo.org>
Load modules by absolute path in busybox modprobe

Our switch to busybox modprobe broke ZFS module loading where busybox
modprobe would load two modules and then fail. Limited developer time
resulted in a hack being put into place to repeat modprobe until ZFS
appeared. However, this was never a real long term solution.

Recent analysis with strace suggests that loading two modules corrupts
busybox's current working directory inside the kernel. Consequently,
subsequent tests where absolute paths were used instead of relative ones
made the problem disappear.

Modifying busybox to use full paths when loading modules makes module
loading work on all affected kernels. While the long term plan is to fix
the kernel, this workaround will be needed indefinitely for affected
kernels, even after mainline Linux is fixed.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Revert "Workaround busybox modprobe's inability to load ZFS modules"

This reverts commit 2fa0a9beaa069a61f907f0b06c9bd6abeddb1ca7.

Signed-off-by: Richard Yao <ryao@gentoo.org>

Conflicts:
	defaults/initrd.scripts
call_func_timeout() should return 1 upon failure

Signed-off-by: Richard Yao <ryao@gentoo.org>