Here is the summary of patches against the current CVS rep. head. See
ChangeLog and my last mail for comments.
Happy hacking,
KR
--
Klaus Reichl @ HOME email: [EMAIL PROTECTED]
Index: ChangeLog
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/ChangeLog,v
retrieving revision 1.166
diff -u -r1.166 ChangeLog
--- ChangeLog 1999/11/06 12:09:37 1.166
+++ ChangeLog 1999/11/07 16:09:16
@@ -1,3 +1,36 @@
+1999-11-06 Klaus Reichl <[EMAIL PROTECTED]>
+
+ * grub/asmstub.c (get_diskinfo) [__linux__]: After opening the
+ drive, flush the cache, other progs may have left over something
+ in the cache.
+
+ * stage2/cmdline.c (enter_cmdline): Repeat if the user hits an
+ empty line (don't complain about unrecognized command in that
+ case).
+
+ * stage2/disk_io.c (check_and_complete_partition): Try to open the
+ partition and if successful add a '/', to allow further <TAB>ing.
+ (print_completions): Use it for floppies and disks.
+
+ * stage2/char_io.c (get_cmdline): Reset ERRNUM if
+ PRINT_COMPLETIONS fail.
+
+ * stage2/builtins.c (root_func): If root is given without
+ argument, print the current root.
+ * docs/user-ref.texi (Command-line-specific commands): Document
+ it.
+
+ * grub/main.c (OPT_ROOT): New option.
+ (longopts): --root
+ (usage): document.
+ (main): setup
+
+ * grub/asmstub.c (root_device): New variable.
+ * stage2/shared.h: ditto.
+
+ * stage2/stage2.c (cmain) [GRUB_UTIL]: In grub shell, check if a
+ root has been given, and set it up.
+
1999-11-06 OKUJI Yoshinori <[EMAIL PROTECTED]>
* grub/asmstub.c (grub_putchar) [HAVE_LIBCURSES]: Do not call
Index: grub/asmstub.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/grub/asmstub.c,v
retrieving revision 1.35
diff -u -r1.35 asmstub.c
--- asmstub.c 1999/11/06 12:09:45 1.35
+++ asmstub.c 1999/11/07 16:09:23
@@ -83,6 +83,7 @@
unsigned long boot_drive = 0;
char version_string[] = VERSION;
char config_file[128] = "/boot/grub/menu.lst"; /* FIXME: arbitrary */
+char root_device[128];
/* Emulation requirements. */
char *grub_scratch_mem = 0;
@@ -915,6 +916,12 @@
return -1;
}
}
+
+#ifdef __linux__
+ /* In Linux, invalidate the buffer cache, so that left overs
+ from other program in the cache are flushed and seen by us */
+ ioctl (disks[drive].flags, BLKFLSBUF, 0);
+#endif
/* Attempt to read the first sector. */
if (read (disks[drive].flags, buf, 512) != 512)
Index: grub/main.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/grub/main.c,v
retrieving revision 1.13
diff -u -r1.13 main.c
--- main.c 1999/10/13 23:02:03 1.13
+++ main.c 1999/11/07 16:09:25
@@ -58,6 +58,7 @@
#define OPT_PROBE_SECOND_FLOPPY -13
#define OPT_NO_FLOPPY -14
#define OPT_DEVICE_MAP -15
+#define OPT_ROOT -16
#define OPTSTRING ""
static struct option longopts[] =
@@ -74,6 +75,7 @@
{"no-floppy", no_argument, 0, OPT_NO_FLOPPY},
{"probe-second-floppy", no_argument, 0, OPT_PROBE_SECOND_FLOPPY},
{"read-only", no_argument, 0, OPT_READ_ONLY},
+ {"root", required_argument, 0, OPT_ROOT},
{"verbose", no_argument, 0, OPT_VERBOSE},
{"version", no_argument, 0, OPT_VERSION},
{0},
@@ -103,6 +105,7 @@
--no-floppy do not probe any floppy drive\n\
--probe-second-floppy probe the second floppy drive\n\
--read-only do not write anything to devices\n\
+ --root=DEVICE set boot_drive and install_partition from root\n\
--verbose print verbose messages\n\
--version print version information and exit\n\
\n\
@@ -179,6 +182,11 @@
perror ("strtoul");
exit (1);
}
+ break;
+
+ case OPT_ROOT:
+ strncpy (root_device, optarg, 127);
+ root_device[127] = '\0';
break;
case OPT_NO_CONFIG_FILE:
Index: stage2/cmdline.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/cmdline.c,v
retrieving revision 1.13
diff -u -r1.13 cmdline.c
--- cmdline.c 1999/10/29 04:33:02 1.13
+++ cmdline.c 1999/11/07 16:09:26
@@ -124,9 +124,15 @@
print_error ();
errnum = ERR_NONE;
- /* Get the command-line with the minimal BASH-like interface. */
- if (get_cmdline (PACKAGE "> ", heap, 2048, 0, 1))
- return;
+ /* Get the command-line with the minimal BASH-like interface.
+ Repeat until we see something on the cmdline. */
+ do
+ {
+ *heap = 0;
+ if (get_cmdline (PACKAGE "> ", heap, 2048, 0, 1))
+ return;
+ }
+ while (heap [0] == '\0' || heap [0] == '#');
/* Find a builtin. */
builtin = find_command (heap);
Index: stage2/disk_io.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/disk_io.c,v
retrieving revision 1.21
diff -u -r1.21 disk_io.c
--- disk_io.c 1999/11/02 12:54:17 1.21
+++ disk_io.c 1999/11/07 16:09:35
@@ -1005,6 +1005,28 @@
* any sane combination of the two.
*/
+static int
+check_and_complete_partition (char * ptr)
+{
+ if (open_partition ())
+ {
+ /* OK add the '/' */
+ if (*(ptr - 1) != ')')
+ {
+ *ptr++ = ')';
+ *ptr = 0;
+ }
+ if (*(ptr - 1) != '/')
+ {
+ *ptr++ = '/';
+ *ptr = 0;
+ }
+ return 1;
+ }
+ else
+ return 0;
+}
+
int
print_completions (int is_filename, int is_completion)
{
@@ -1104,8 +1126,7 @@
}
else
{
- *ptr++ = ')';
- *ptr = 0;
+ check_and_complete_partition (ptr);
}
}
}
@@ -1131,18 +1152,8 @@
}
}
else
- {
- if (open_partition ())
- {
- unique = 1;
- ptr = buf + grub_strlen (buf);
- if (*(ptr - 1) != ')')
- {
- *ptr++ = ')';
- *ptr = 0;
- }
- }
- }
+ unique =
+ check_and_complete_partition (buf + grub_strlen (buf));
}
}
else if (ptr && *ptr == '/')
Index: stage2/char_io.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/char_io.c,v
retrieving revision 1.18
diff -u -r1.18 char_io.c
--- char_io.c 1999/11/02 12:54:16 1.18
+++ char_io.c 1999/11/07 16:09:39
@@ -419,6 +419,10 @@
print_completions (is_filename, 0);
}
}
+ else
+ /* if print_completions signals an error make sure we
+ don't leave this hanging */
+ errnum = ERR_NONE;
/* Restore the command-line. */
if (equal_pos >= 0)
Index: stage2/builtins.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/builtins.c,v
retrieving revision 1.36
diff -u -r1.36 builtins.c
--- builtins.c 1999/11/06 12:09:46 1.36
+++ builtins.c 1999/11/07 16:09:56
@@ -1849,6 +1849,35 @@
char *biasptr;
char *next;
+ /* If arg is empty just print current value */
+ if (!arg[0])
+ {
+ /* check if drive/partition is plausible */
+ if (!open_partition ())
+ grub_printf (" Current drive 0x%x, current partition 0x%x\n",
+ current_drive, current_partition);
+ else
+ {
+ grub_printf (" root=(");
+ if (current_drive == 0x20)
+ grub_printf ("nd");
+ else if (current_drive >= 0x80)
+ {
+ grub_printf ("hd%d,%d",
+ current_drive - 0x80,
+ /* XXX: Is this correct in any case? */
+ current_partition >> 16);
+ }
+ else
+ {
+ grub_printf ("fd%d", current_drive);
+ }
+ grub_printf (")\n");
+ }
+
+ return 0;
+ }
+
/* Call set_device to get the drive and the partition in ARG. */
next = set_device (arg);
if (! next)
Index: stage2/stage2.c
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/stage2.c,v
retrieving revision 1.9
diff -u -r1.9 stage2.c
--- stage2.c 1999/10/29 04:33:04 1.9
+++ stage2.c 1999/11/07 16:10:00
@@ -583,6 +583,24 @@
/* Initialize the kill buffer. */
*kill = 0;
+#ifdef GRUB_UTIL
+ /* Setup possible root given by user */
+ if (root_device[0])
+ {
+ struct builtin *builtin;
+
+ builtin = find_command ("root");
+ if ((builtin->func) (root_device, BUILTIN_CMDLINE))
+ {
+ extern int sleep (int secs); /* XXX */
+
+ grub_printf ("\nError: %s\n", err_list[errnum]);
+ /* How to tell the user, that something goes wrong here? */
+ sleep (2);
+ }
+ }
+#endif
+
/* Never return. */
for (;;)
{
Index: stage2/shared.h
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/stage2/shared.h,v
retrieving revision 1.32
diff -u -r1.32 shared.h
--- shared.h 1999/11/02 12:54:19 1.32
+++ shared.h 1999/11/07 16:10:06
@@ -430,6 +430,8 @@
extern char **device_map;
/* The filename which stores the information about a device map. */
extern char *device_map_file;
+/* The root device specified by the user */
+extern char root_device[];
/* The array of geometries. */
extern struct geometry *disks;
/* Check if DEVICE can be read. If an error occurs, return zero,
Index: docs/user-ref.texi
===================================================================
RCS file: /gd/gnu/anoncvsroot/grub/docs/user-ref.texi,v
retrieving revision 1.10
diff -u -r1.10 user-ref.texi
--- user-ref.texi 1999/11/03 08:44:57 1.10
+++ user-ref.texi 1999/11/07 16:10:19
@@ -921,8 +921,8 @@
hex format.
@end deffn
-@deffn Command root device [hdbias]
-Set the current @dfn{root device} to the device @var{device}, then
+@deffn Command root [device [hdbias]]
+Print or set the current @dfn{root device} to the device @var{device}, then
attempt to mount it to get the partition size (for passing the partition
descriptor in @code{ES:ESI}, used by some chain-loaded boot loaders), the
BSD drive-type (for booting BSD kernels using their native boot format),