=== modified file 'ChangeLog' --- ChangeLog 2010-08-19 23:15:23 +0000 +++ ChangeLog 2010-08-20 14:34:56 +0000 @@ -1,3 +1,13 @@ +2010-08-20 Robert Millan + + Make kFreeBSD code more generic to support ext2fs as root, ufs as + a separate module and maybe other interesting combinations. + + * util/grub.d/10_kfreebsd.in (load_kfreebsd_module): New function. + (kfreebsd_entry): Use load_kfreebsd_module() to load modules. + (kfreebsd_entry): Add generic filesystem module load routine. + Map GRUB `ext2' to kFreeBSD `ext2fs'. + 2010-08-20 Colin Watson * commands/i386/pc/sendkey.c (keysym_table): Rename "numlock" to === modified file 'util/grub.d/10_kfreebsd.in' --- util/grub.d/10_kfreebsd.in 2010-08-08 14:27:58 +0000 +++ util/grub.d/10_kfreebsd.in 2010-08-20 14:29:50 +0000 @@ -39,6 +39,31 @@ case "${GRUB_DISTRIBUTOR}" in ;; esac +load_kfreebsd_module () +{ + mod="$1" + allow_fail="$2" + + if ! test -e "${module_dir}/${mod}.ko" ; then + if [ "${allow_fail}" = "true" ] ; then + # Return silently + return + else + # Print an error and fail. + ls "${module_dir}/${mod}.ko" > /dev/null + fi + fi + + if [ -z "${prepare_module_dir_cache}" ]; then + prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")" + fi + + printf '%s\n' "${prepare_module_dir_cache}" + cat << EOF + kfreebsd_module_elf ${module_dir_rel}/${mod}.ko +EOF +} + kfreebsd_entry () { os="$1" @@ -51,9 +76,6 @@ kfreebsd_entry () if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi - if [ -z "${prepare_module_dir_cache}" ]; then - prepare_module_dir_cache="$(prepare_grub_to_access_device $(grub-probe -t device "${module_dir}") | sed -e "s/^/\t/")" - fi printf '%s\n' "${prepare_boot_cache}" cat << EOF @@ -67,26 +89,13 @@ EOF EOF fi - if test -e "${module_dir}/acpi.ko" ; then - printf '%s\n' "${prepare_module_dir_cache}" - cat << EOF - kfreebsd_module_elf ${module_dir_rel}/acpi.ko -EOF - fi + load_kfreebsd_module acpi true case "${kfreebsd_fs}" in zfs) - for i in "${module_dir}/opensolaris.ko" "${module_dir}/zfs.ko" \ - "${dirname}/zfs/zpool.cache" ; do - ls "$i" > /dev/null - done - - printf '%s\n' "${prepare_module_dir_cache}" - cat << EOF - kfreebsd_module_elf ${module_dir_rel}/opensolaris.ko - kfreebsd_module_elf ${module_dir_rel}/zfs.ko -EOF + load_kfreebsd_module opensolaris false + ls "${dirname}/zfs/zpool.cache" > /dev/null printf '%s\n' "${prepare_boot_cache}" cat << EOF kfreebsd_module ${rel_dirname}/zfs/zpool.cache type=/boot/zfs/zpool.cache @@ -94,6 +103,8 @@ EOF ;; esac + load_kfreebsd_module ${kfreebsd_fs} false + cat << EOF set kFreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${kfreebsd_device} set kFreeBSD.vfs.root.mountfrom.options=rw @@ -121,8 +132,9 @@ while [ "x$list" != "x" ] ; do fi case ${GRUB_FS} in - ufs1 | ufs2) kfreebsd_fs=ufs ;; - *) kfreebsd_fs=${GRUB_FS} ;; + ufs1 | ufs2) kfreebsd_fs=ufs ;; + ext2) kfreebsd_fs=ext2fs ;; + *) kfreebsd_fs=${GRUB_FS} ;; esac case ${GRUB_FS} in