bsd: Ensure that kernel is loaded before loading module.

kernel_type may be set to the type of failed kernel. This patching-up is
easier than to reflow kernel loading routines.
This commit is contained in:
Vladimir Serbinenko 2016-02-26 14:56:22 +01:00
parent 8c26dace6f
commit 2ebef43cf6

View file

@ -1889,6 +1889,10 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)),
grub_err_t err; grub_err_t err;
void *src; void *src;
if (! grub_loader_is_loaded ())
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("you need to load the kernel first"));
if (kernel_type != KERNEL_TYPE_FREEBSD) if (kernel_type != KERNEL_TYPE_FREEBSD)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded");
@ -1992,6 +1996,10 @@ grub_cmd_netbsd_module (grub_command_t cmd,
{ {
grub_uint32_t type; grub_uint32_t type;
if (! grub_loader_is_loaded ())
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("you need to load the kernel first"));
if (kernel_type != KERNEL_TYPE_NETBSD) if (kernel_type != KERNEL_TYPE_NETBSD)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded");
@ -2070,6 +2078,10 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)),
if (argc != 1) if (argc != 1)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
if (! grub_loader_is_loaded ())
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("you need to load the kernel first"));
if (kernel_type != KERNEL_TYPE_OPENBSD) if (kernel_type != KERNEL_TYPE_OPENBSD)
return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded"); return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded");