Add new options into /sbin/grub, and eliminate the completion code from Stage 1.5.
This commit is contained in:
parent
cc1aa59379
commit
447e862f7e
7 changed files with 131 additions and 9 deletions
28
ChangeLog
28
ChangeLog
|
@ -1,3 +1,31 @@
|
|||
1999-06-02 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||
|
||||
* grub/main.c (verbose): New variable.
|
||||
(read_only): Likewise.
|
||||
(OPT_VERBOSE): New macro.
|
||||
(OPT_READ_ONLY): Likewise.
|
||||
(longopts): Add --read-only and --verbose options.
|
||||
(usage): Add the descriptions about --read-only and --verbose.
|
||||
(main): Handle OPT_VERBOSE and OPT_READ_ONLY.
|
||||
If HOLD and VERBOSE are non-zero, then display the message
|
||||
about how to restart /sbin/grub.
|
||||
|
||||
* shared_src/shared.h (verbose) [GRUB_UTIL]: Declared.
|
||||
(read_only) [GRUB_UTIL]: Likewise.
|
||||
|
||||
* grub/asmstub.c (hex_dump): New function.
|
||||
(biosdisk): In the case where SUBFUNC is
|
||||
BIOSDISK_WRITE, check for READ_ONLY and call nwrite if
|
||||
READ_ONLY is zero. If VERBOSE is non-zero, display what GRUB
|
||||
will try to do.
|
||||
(get_diskinfo): Open DEVNAME with the mode O_RDWR if READ_ONLY
|
||||
is zero, and attempt to open DEVNAME with the mode O_RDONLY
|
||||
regardless of ERRNO if READ_ONLY is non-zero. If VERBOSE is
|
||||
non-zero, then display the drive DRIVE and the file DEVNAME.
|
||||
|
||||
* shared_src/disk_io.c (set_device) [STAGE1_5]: Eliminate
|
||||
completion code.
|
||||
|
||||
1999-06-01 OKUJI Yoshinori <okuji@kuicr.kyoto-u.ac.jp>
|
||||
|
||||
* grub/asmstub.c: Do not use I_AM_VERY_BRAVE any more.
|
||||
|
|
9
NEWS
9
NEWS
|
@ -1,8 +1,13 @@
|
|||
NEWS - list of user-visible changes between releases of GRUB
|
||||
|
||||
New:
|
||||
* The /sbin/grub stage2 simulator now works for simple cases, and uses
|
||||
the Linux HDIO_GETGEO ioctl to determine hard disk geometry.
|
||||
* The /sbin/grub stage2 simulator now works at least on GNU/Linux, and
|
||||
uses the Linux HDIO_GETGEO ioctl to determine hard disk geometry.
|
||||
* TAB not only lists filenames, but also completes a filename when the
|
||||
filename is unique.
|
||||
* Many bug fixes (i.e. Stage 1.5 can work fine again).
|
||||
* Password is not echoed back, put an asterisk for each of input
|
||||
characters.
|
||||
|
||||
New in 0.5.91 - 1999-03-14, Gordon Matzigkeit:
|
||||
* LBA and preliminary AWARD BIOS disk extension support.
|
||||
|
|
3
TODO
3
TODO
|
@ -4,9 +4,6 @@ Change partition syntax to correspond with BSD ``slice'' syntax
|
|||
Add a partition naming syntax that means ``the first partition of this
|
||||
type''. We need this for clean Hurd install floppies.
|
||||
|
||||
Find out the size restrictions for FAT and ext2fs stage1.5 boot
|
||||
blocks. Enforce all arbitrary limits using the Makefiles.
|
||||
|
||||
Add a real scripting language, possibly retaining backward
|
||||
compatibility so that old config files can be used.
|
||||
|
||||
|
|
|
@ -508,11 +508,17 @@ get_diskinfo (int drive, struct geometry *geometry)
|
|||
if (! devname)
|
||||
return -1;
|
||||
|
||||
if (verbose)
|
||||
grub_printf ("Attempt to open drive 0x%x (%s)\n",
|
||||
drive, devname);
|
||||
|
||||
/* Open read/write, or read-only if that failed. */
|
||||
disks[drive].flags = open (devname, O_RDWR);
|
||||
if (! read_only)
|
||||
disks[drive].flags = open (devname, O_RDWR);
|
||||
|
||||
if (disks[drive].flags == -1)
|
||||
{
|
||||
if (errno == EACCES || errno == EROFS)
|
||||
if (read_only || errno == EACCES || errno == EROFS)
|
||||
{
|
||||
disks[drive].flags = open (devname, O_RDONLY);
|
||||
if (disks[drive].flags == -1)
|
||||
|
@ -632,6 +638,55 @@ nwrite (int fd, char *buf, size_t len)
|
|||
return size;
|
||||
}
|
||||
|
||||
/* Dump BUF in the format of hexadecimal numbers. */
|
||||
static void
|
||||
hex_dump (void *buf, size_t size)
|
||||
{
|
||||
/* FIXME: How to determine which length is readable? */
|
||||
#define MAX_COLUMN 70
|
||||
|
||||
/* use unsigned char for numerical computations */
|
||||
unsigned char *ptr = buf;
|
||||
/* count the width of the line */
|
||||
int column = 0;
|
||||
/* how many bytes written */
|
||||
int count = 0;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
/* high 4 bits */
|
||||
int hi = *ptr >> 4;
|
||||
/* low 4 bits */
|
||||
int low = *ptr & 0xf;
|
||||
|
||||
/* grub_printf does not handle prefix number, such as %2x, so
|
||||
format the number by hand... */
|
||||
grub_printf ("%x%x", hi, low);
|
||||
column += 2;
|
||||
count++;
|
||||
ptr++;
|
||||
size--;
|
||||
|
||||
/* Insert space or newline with the interval 4 bytes. */
|
||||
if (size != 0 && (count % 4) == 0)
|
||||
{
|
||||
if (column < MAX_COLUMN)
|
||||
{
|
||||
grub_printf (" ");
|
||||
column++;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf ("\n");
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a newline at the end for readability. */
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
int
|
||||
biosdisk (int subfunc, int drive, struct geometry *geometry,
|
||||
int sector, int nsec, int segment)
|
||||
|
@ -669,10 +724,20 @@ biosdisk (int subfunc, int drive, struct geometry *geometry,
|
|||
if (nread (fd, buf, nsec * SECTOR_SIZE) != nsec * SECTOR_SIZE)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case BIOSDISK_WRITE:
|
||||
if (nwrite (fd, buf, nsec * SECTOR_SIZE) != nsec * SECTOR_SIZE)
|
||||
return -1;
|
||||
if (verbose)
|
||||
{
|
||||
grub_printf ("Write %d sectors starting from %d sector"
|
||||
" to drive 0x%x (%s)\n",
|
||||
nsec, sector, drive, device_map[drive]);
|
||||
hex_dump (buf, nsec * SECTOR_SIZE);
|
||||
}
|
||||
if (! read_only)
|
||||
if (nwrite (fd, buf, nsec * SECTOR_SIZE) != nsec * SECTOR_SIZE)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
grub_printf ("unknown subfunc %d\n", subfunc);
|
||||
break;
|
||||
|
|
19
grub/main.c
19
grub/main.c
|
@ -34,6 +34,8 @@ int grub_stage2 (void);
|
|||
char *program_name = 0;
|
||||
int use_config_file = 1;
|
||||
int use_curses = 1;
|
||||
int verbose = 0;
|
||||
int read_only = 0;
|
||||
static int default_boot_drive;
|
||||
static int default_install_partition;
|
||||
static char *default_config_file;
|
||||
|
@ -47,6 +49,8 @@ static char *default_config_file;
|
|||
#define OPT_NO_CONFIG_FILE -8
|
||||
#define OPT_NO_CURSES -9
|
||||
#define OPT_BATCH -10
|
||||
#define OPT_VERBOSE -11
|
||||
#define OPT_READ_ONLY -12
|
||||
#define OPTSTRING ""
|
||||
|
||||
static struct option longopts[] =
|
||||
|
@ -60,6 +64,8 @@ static struct option longopts[] =
|
|||
{"no-config-file", no_argument, 0, OPT_NO_CONFIG_FILE},
|
||||
{"no-curses", no_argument, 0, OPT_NO_CURSES},
|
||||
{"batch", no_argument, 0, OPT_BATCH},
|
||||
{"verbose", no_argument, 0, OPT_VERBOSE},
|
||||
{"read-only", no_argument, 0, OPT_READ_ONLY},
|
||||
{0},
|
||||
};
|
||||
|
||||
|
@ -83,6 +89,8 @@ Enter the GRand Unified Bootloader command shell.\n\
|
|||
--install-partition=PAR specify stage2 install_partition [default=0x%x]\n\
|
||||
--no-config-file do not use the config file\n\
|
||||
--no-curses do not use curses\n\
|
||||
--read-only do not write anything to devices\n\
|
||||
--verbose print verbose messages\n\
|
||||
--version print version information and exit\n\
|
||||
\n\
|
||||
Report bugs to bug-grub@gnu.org\n\
|
||||
|
@ -167,6 +175,14 @@ main (int argc, char **argv)
|
|||
use_curses = 0;
|
||||
break;
|
||||
|
||||
case OPT_READ_ONLY:
|
||||
read_only = 1;
|
||||
break;
|
||||
|
||||
case OPT_VERBOSE:
|
||||
verbose = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (1);
|
||||
}
|
||||
|
@ -174,6 +190,9 @@ main (int argc, char **argv)
|
|||
while (c != EOF);
|
||||
|
||||
/* Wait until the HOLD variable is cleared by an attached debugger. */
|
||||
if (hold && verbose)
|
||||
grub_printf ("Run \"gdb %s %d\", and set HOLD to zero.\n",
|
||||
program_name, (int) getpid ());
|
||||
while (hold)
|
||||
sleep (1);
|
||||
|
||||
|
|
|
@ -599,9 +599,11 @@ set_device (char *device)
|
|||
current_drive = saved_drive;
|
||||
current_partition = 0xFFFFFF;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
if (*device == '(' && !*(device + 1))
|
||||
/* user has given '(' only, let disk_choice handle what disks we have */
|
||||
return device + 1;
|
||||
#endif
|
||||
|
||||
if (*device == '(' && *(++device))
|
||||
{
|
||||
|
@ -609,6 +611,7 @@ set_device (char *device)
|
|||
{
|
||||
char ch = *device;
|
||||
|
||||
#ifndef STAGE1_5
|
||||
if (*device == 'f' || *device == 'h')
|
||||
{
|
||||
/* user has given '([fh]', check for resp. add 'd' and
|
||||
|
@ -623,6 +626,7 @@ set_device (char *device)
|
|||
else if (*(device + 1) == 'd' && !*(device + 2))
|
||||
return device + 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((*device == 'f' || *device == 'h')
|
||||
&& (device += 2, (*(device - 1) != 'd')))
|
||||
|
|
|
@ -288,6 +288,10 @@ extern char config_file[];
|
|||
extern int use_config_file;
|
||||
/* If not using curses, this variable is set to zero, otherwise non-zero. */
|
||||
extern int use_curses;
|
||||
/* The flag for verbose messages. */
|
||||
extern int verbose;
|
||||
/* The flag for read-only. */
|
||||
extern int read_only;
|
||||
#endif
|
||||
|
||||
#ifndef STAGE1_5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue