2002-04-06 Yoshinori K. Okuji <okuji@enbug.org>

* stage2/builtins.c [GRUB_UTIL] (dump_func): New function.
	[GRUB_UTIL] (builtin_dump): New variable.
	(builtin_table) [GRUB_UTIL]: Added a pointer to BUILTIN_DUMP.
	* util/grub-install.in: Make sure that GRUB reads the same
	images as the host operating system by comparing the result of
	running the command "dump" with the contents of the OS file.
This commit is contained in:
okuji committed 2002-04-06 12:15:13 +00:00
1 parent cfce0b1fae
commit 86d5582ec2
5 files changed
+115 -7

No files matched your search

+63
View File
@@ -973,6 +973,66 @@ static struct builtin builtin_displaymem =
" machine is, including all regions of physical RAM installed."
};
/* dump FROM TO */
#ifdef GRUB_UTIL
static int
dump_func (char *arg, int flags)
{
char *from, *to;
FILE *fp;
char c;
from = arg;
to = skip_to (0, arg);
if (! *from || ! *to)
{
errnum = ERR_BAD_ARGUMENT;
return 1;
}
nul_terminate (from);
nul_terminate (to);
if (! grub_open (from))
return 1;
fp = fopen (to, "w");
if (! fp)
{
errnum = ERR_WRITE;
return 1;
}
while (grub_read (&c, 1))
if (fputc (c, fp) == EOF)
{
errnum = ERR_WRITE;
fclose (fp);
return 1;
}
if (fclose (fp) == EOF)
{
errnum = ERR_WRITE;
return 1;
}
grub_close ();
return 0;
}
static struct builtin builtin_dump =
{
"dump",
dump_func,
BUILTIN_CMDLINE,
"dump FROM TO",
"Dump the contents of the file FROM to the file TO. FROM must be"
" a GRUB file and TO must be an OS file."
};
#endif /* GRUB_UTIL */
static char embed_info[32];
/* embed */
@@ -4528,6 +4588,9 @@ struct builtin *builtin_table[] =
#endif /* SUPPORT_NETBOOT */
&builtin_displayapm,
&builtin_displaymem,
#ifdef GRUB_UTIL
&builtin_dump,
#endif /* GRUB_UTIL */
&builtin_embed,
&builtin_fallback,
&builtin_find,