make the argument address for the command install optional.

This commit is contained in:
okuji 1999-09-19 21:00:59 +00:00
parent dc73edd77c
commit 133581fe5c
5 changed files with 71 additions and 24 deletions

View file

@ -1,3 +1,22 @@
1999-09-20 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
The argument ADDR for the command install is now optional.
* stage2/builtins.c (install_func): If parsing ADDR fails, set
INSTALLADDR to zero and set PTR to ADDR.
If INSTALLADDR is zero after parsing the command-line, check if
the Stage 2 id is STAGE2_ID_STAGE2. If so, set INSTALLADDR to
0x8000, otherwise set it to 0x2000.
Set the install address in the Stage 1 after the automatic
determination is completed.
(builtin_install): Say that ADDR is optional in the help
message.
* docs/grub.texi: Synchronize the description about install to
builtins.c. Remove explicit address arguments from all the
examples. Add a description about help.
* docs/menu.lst: Do not specify the address argument for
install.
1999-09-19 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp> 1999-09-19 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
The completion code is heavily modified. The completion code is heavily modified.

1
NEWS
View file

@ -26,6 +26,7 @@ New in 0.5.93:
* FreeBSD support in the grub shell is improved. * FreeBSD support in the grub shell is improved.
* Killing (C-u and C-k), yanking (C-y) and manipulating the history * Killing (C-u and C-k), yanking (C-y) and manipulating the history
(C-p and C-n) are supported. (C-p and C-n) are supported.
* The address argument for the command "install" is now optional.
New in 0.5.92 - 1999-07-26: New in 0.5.92 - 1999-07-26:
* Bug fixes (i.e. Stage 1.5 can work fine again). * Bug fixes (i.e. Stage 1.5 can work fine again).

View file

@ -431,7 +431,7 @@ configuration file), then run the following command at GRUB's command
line (after booting from the GRUB floppy): line (after booting from the GRUB floppy):
@example @example
install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 0x8000 p install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 p
@end example @end example
This tells GRUB to grab the first sector of the floppy and use it as the This tells GRUB to grab the first sector of the floppy and use it as the
@ -448,7 +448,7 @@ telling GRUB's stage1 to read from the first hard disk no matter where
the stage1 was loaded from: the stage1 was loaded from:
@example @example
install (fd0)+1 d (fd0) (hd0,1)/boot/grub/stage2 0x8000 p install (fd0)+1 d (fd0) (hd0,1)/boot/grub/stage2 p
@end example @end example
By default, GRUB loads the stage2 from the disk where the stage1 was By default, GRUB loads the stage2 from the disk where the stage1 was
@ -474,7 +474,7 @@ dd if=stage2/e2fs_stage1_5 of=/dev/hda bs=512 seek=1
Second, specify the stage1.5 argument in blocklist format: Second, specify the stage1.5 argument in blocklist format:
@example @example
install (fd0)+1 (hd0) (hd0)1+1 0x2000 p (hd0,1)/boot/grub/stage2 install (fd0)+1 (hd0) (hd0)1+1 p (hd0,1)/boot/grub/stage2
@end example @end example
@item @item
@ -485,7 +485,7 @@ hard disk, and setting the stage2's @dfn{configuration file} to
@file{(hd1,a)/grubdir/configfile}: @file{(hd1,a)/grubdir/configfile}:
@example @example
install (hd0,1)/boot/grub/stage1 (hd1) (hd1,a)/boot/grub/stage2 0x8000 p /grubdir/configfile install (hd0,1)/boot/grub/stage1 (hd1) (hd1,a)/boot/grub/stage2 p /grubdir/configfile
@end example @end example
@end itemize @end itemize
@ -497,7 +497,7 @@ and a configuration file which contains entries such as:
title GNU/Linux installation title GNU/Linux installation
# Installation command: # Installation command:
install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 0x8000 p install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 p
# Actually boot here: # Actually boot here:
root (hd0,1) root (hd0,1)
@ -784,6 +784,12 @@ requests from the disk.
Filesystem test mode is turned off by any use of the @command{install} Filesystem test mode is turned off by any use of the @command{install}
or @command{testload} commands. or @command{testload} commands.
@item help [@var{pattern} @dots{}]
Display helpful information about builtin commands. If you do not
specify @var{pattern}, this command lists the short documents of all
available commands, and, if you specify one or more @var{pattern}s, it
displays long documents of the commands which match @var{pattern}.
@item hide @var{partition} @item hide @var{partition}
Hide @var{partition} by setting the @dfn{hidden} bit in its partition Hide @var{partition} by setting the @dfn{hidden} bit in its partition
type code. type code.
@ -796,7 +802,7 @@ table and boot the various CPUs which are found into a tight loop.
Load an initial ramdisk for a Linux format boot image and set the Load an initial ramdisk for a Linux format boot image and set the
appropriate parameters in the Linux setup area in memory. appropriate parameters in the Linux setup area in memory.
@item install @var{stage1-file} [d] @var{dest-device} @var{file} @var{addr} [p] [@var{config-file}] @item install @var{stage1-file} [d] @var{dest-device} @var{file} [@var{addr}] [p] [@var{config-file}]
This command is fairly complex, and for detailed examples one should This command is fairly complex, and for detailed examples one should
look at @ref{Automated install}. In short, it will perform a full look at @ref{Automated install}. In short, it will perform a full
install presuming the stage2 or stage1.5@footnote{They're loaded the install presuming the stage2 or stage1.5@footnote{They're loaded the
@ -809,14 +815,15 @@ loading @var{file} as a stage2. If the option @samp{d} is present, the
stage1 will always look for the actual disk @var{file} was installed on, stage1 will always look for the actual disk @var{file} was installed on,
rather than using the booting drive. The stage2 will be loaded at rather than using the booting drive. The stage2 will be loaded at
address @var{addr}, which must be @samp{0x8000} for a true stage2, and address @var{addr}, which must be @samp{0x8000} for a true stage2, and
@samp{0x2000} for a stage1.5. It then writes the completed stage1 to @samp{0x2000} for a stage1.5. If @var{addr} is not present, GRUB will
the first block of the device @var{dest-dev}. If the options @samp{p} or determine the address automatically. It then writes the completed stage1
@var{config-file} are present, then it reads the first block of stage2, to the first block of the device @var{dest-dev}. If the options @samp{p}
modifies it with the values of the partition @var{file} was found on or @var{config-file} are present, then it reads the first block of
(for @samp{p}) or places the string @var{config-file} into the area stage2, modifies it with the values of the partition @var{file} was
telling the stage2 where to look for a configuration file at boot time. found on (for @samp{p}) or places the string @var{config-file} into the
This command preserves the DOS BPB (and for hard disks, the partition area telling the stage2 where to look for a configuration file at boot
table) of the sector the stage1 is to be installed into. time. This command preserves the DOS BPB (and for hard disks, the
partition table) of the sector the stage1 is to be installed into.
@item kernel @var{file} @dots{} @item kernel @var{file} @dots{}
Attempt to load the primary boot image (Multiboot a.out or @sc{elf}, Attempt to load the primary boot image (Multiboot a.out or @sc{elf},
@ -1286,7 +1293,7 @@ option in the command line. This is a simple example:
/sbin/grub --batch <<EOT 1>/dev/null 2>/dev/null /sbin/grub --batch <<EOT 1>/dev/null 2>/dev/null
root (hd0,0) root (hd0,0)
install /boot/grub/stage1 (hd0) /boot/grub/stage2 0x8000 p install /boot/grub/stage1 (hd0) /boot/grub/stage2 p
quit quit
EOT EOT
@end example @end example

View file

@ -44,10 +44,10 @@ title Windows NT / Windows 95 boot menu
root (hd0,0) root (hd0,0)
makeactive makeactive
chainloader +1 chainloader +1
# For loading DOS if Windows NT is installed
# chainload /bootsect.dos
# For installing GRUB into the hard disk # For installing GRUB into the hard disk
title Install GRUB into the hard disk title Install GRUB into the hard disk
root (hd0,0) root (hd0,0)
install /boot/grub/stage1 d (hd0) /boot/grub/stage2 0x8000 p install /boot/grub/stage1 d (hd0) /boot/grub/stage2 p
# For loading DOS if Windows NT is installed
# chainload /bootsect.dos

View file

@ -768,7 +768,14 @@ install_func (char *arg, int flags)
/* Get the installation address. */ /* Get the installation address. */
if (! safe_parse_maxint (&addr, &installaddr)) if (! safe_parse_maxint (&addr, &installaddr))
return 1; {
/* ADDR is not specified. */
installaddr = 0;
ptr = addr;
errnum = 0;
}
else
ptr = skip_to (0, addr);
/* Read Stage 1. */ /* Read Stage 1. */
if (! grub_open (stage1_file) if (! grub_open (stage1_file)
@ -867,8 +874,6 @@ install_func (char *arg, int flags)
*((unsigned char *) (BOOTSEC_LOCATION + STAGE1_FIRSTLIST)) *((unsigned char *) (BOOTSEC_LOCATION + STAGE1_FIRSTLIST))
= new_drive; = new_drive;
*((unsigned short *) (BOOTSEC_LOCATION + STAGE1_INSTALLADDR))
= installaddr;
i = BOOTSEC_LOCATION+STAGE1_FIRSTLIST - 4; i = BOOTSEC_LOCATION+STAGE1_FIRSTLIST - 4;
while (*((unsigned long *) i)) while (*((unsigned long *) i))
@ -905,8 +910,23 @@ install_func (char *arg, int flags)
return 1; return 1;
} }
/* If INSTALLADDR is not specified explicitly in the command-line,
determine it by the Stage 2 id. */
if (! installaddr)
{
if (*((unsigned char *) (SCRATCHADDR + STAGE2_STAGE2_ID))
== STAGE2_ID_STAGE2)
/* Stage 2. */
installaddr = 0x8000;
else
/* Stage 1.5. */
installaddr = 0x2000;
}
*((unsigned short *) (BOOTSEC_LOCATION + STAGE1_INSTALLADDR))
= installaddr;
stage2_sect = installsect; stage2_sect = installsect;
ptr = skip_to (0, addr);
if (*ptr == 'p') if (*ptr == 'p')
{ {
@ -965,12 +985,12 @@ static struct builtin builtin_install =
"install", "install",
install_func, install_func,
BUILTIN_CMDLINE, BUILTIN_CMDLINE,
"install STAGE1 [d] DEVICE STAGE2 ADDR [p] [CONFIG_FILE]", "install STAGE1 [d] DEVICE STAGE2 [ADDR] [p] [CONFIG_FILE]",
"Install STAGE1 on DEVICE, and install a blocklist for loading STAGE2" "Install STAGE1 on DEVICE, and install a blocklist for loading STAGE2"
" as a Stage 2. If the option `d' is present, the Stage 1 will always" " as a Stage 2. If the option `d' is present, the Stage 1 will always"
" look for the disk where STAGE2 was installed, rather than using" " look for the disk where STAGE2 was installed, rather than using"
" the booting drive. The Stage 2 will be loaded at address ADDR, which" " the booting drive. The Stage 2 will be loaded at address ADDR, which"
" must be 0x8000 for a true Stage 2, and 0x2000 for a Stage 1.5. If" " will be determined automatically if you don't specify it. If"
" the option `p' or CONFIG_FILE is present, then the first block" " the option `p' or CONFIG_FILE is present, then the first block"
" of Stage 2 is patched with new values of the partition and name" " of Stage 2 is patched with new values of the partition and name"
" of the configuration file used by the true Stage 2 (for a Stage 1.5," " of the configuration file used by the true Stage 2 (for a Stage 1.5,"