2004-09-12 Tomas Ebenlendr <ebik@ucw.cz>

Added normal mode command `chainloader' as module chain.mod, which
	depends on normal.mod and _chain.mod.

	* conf/i386-pc.rmk (pkgdata_MODULES): Add `chain.mod'.
	(chain_mod_SOURCES, chain_mod_CFLAGS): Variables added.
	* include/grub/i386/pc/loader.h (grub_rescue_cmd_chainloader):
	Deleted prototype.
	* loader/i386/pc/chainloader.c (grub_rescue_cmd_chainloader): All
	but arguments parsing moved to ...
	(grub_chainloader_cmd): ... here.  New function.
	* include/grub/i386/pc/chainloader.h: New file.
	* loader/i386/pc/chainloader_normal.c: Likewise.
This commit is contained in:
marco_g 2004-09-12 12:20:52 +00:00
parent 2c1f4ce368
commit 8ddad8453b
7 changed files with 176 additions and 22 deletions

View file

@ -1,7 +1,7 @@
/* chainloader.c - boot another boot loader */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc.
* Copyright (C) 2002,2004 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,6 +20,7 @@
#include <grub/loader.h>
#include <grub/machine/loader.h>
#include <grub/machine/chainloader.h>
#include <grub/file.h>
#include <grub/err.h>
#include <grub/device.h>
@ -82,28 +83,14 @@ grub_chainloader_unload (void)
}
void
grub_rescue_cmd_chainloader (int argc, char *argv[])
grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
{
grub_file_t file = 0;
grub_uint16_t signature;
int force = 0;
grub_dl_ref (my_mod);
if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
{
force = 1;
argc--;
argv++;
}
if (argc == 0)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
goto fail;
}
file = grub_file_open (argv[0]);
file = grub_file_open (filename);
if (! file)
goto fail;
@ -119,7 +106,8 @@ grub_rescue_cmd_chainloader (int argc, char *argv[])
/* Check the signature. */
signature = *((grub_uint16_t *) (0x7C00 + GRUB_DISK_SECTOR_SIZE - 2));
if (signature != grub_le_to_cpu16 (0xaa55) && ! force)
if (signature != grub_le_to_cpu16 (0xaa55)
&& ! (flags & GRUB_CHAINLOADER_FORCE))
{
grub_error (GRUB_ERR_BAD_OS, "invalid signature");
goto fail;
@ -137,6 +125,24 @@ grub_rescue_cmd_chainloader (int argc, char *argv[])
grub_dl_unref (my_mod);
}
static void
grub_rescue_cmd_chainloader (int argc, char *argv[])
{
grub_chainloader_flags_t flags = 0;
if (argc > 0 && grub_strcmp (argv[0], "--force") == 0)
{
flags |= GRUB_CHAINLOADER_FORCE;
argc--;
argv++;
}
if (argc == 0)
grub_error (GRUB_ERR_BAD_ARGUMENT, "no file specified");
else
grub_chainloader_cmd (argv[0], flags);
}
static const char loader_name[] = "chainloader";
GRUB_MOD_INIT