diff -ur grub.new/configure.ac grub/configure.ac
--- grub.new/configure.ac	2004-06-20 15:48:46.000000000 +0200
+++ grub/configure.ac	2004-06-13 19:49:48.000000000 +0200
@@ -666,5 +666,5 @@
 		 docs/Makefile lib/Makefile util/Makefile \
 		 grub/Makefile netboot/Makefile util/grub-image \
 		 util/grub-install util/grub-md5-crypt \
-		 util/grub-terminfo util/grub-set-default])
+		 util/grub-terminfo])
 AC_OUTPUT
diff -ur grub.new/stage2/asm.S grub/stage2/asm.S
--- grub.new/stage2/asm.S	2004-06-20 15:48:46.000000000 +0200
+++ grub/stage2/asm.S	2004-05-23 18:45:43.000000000 +0200
@@ -87,7 +87,6 @@
 
 VARIABLE(install_partition)
 	.long	0xFFFFFF
-/* This variable is here only because of a historical reason.  */
 VARIABLE(saved_entryno)
 	.long	0
 VARIABLE(stage2_id)
diff -ur grub.new/stage2/builtins.c grub/stage2/builtins.c
--- grub.new/stage2/builtins.c	2004-06-20 15:48:46.000000000 +0200
+++ grub/stage2/builtins.c	2004-05-14 22:16:55.000000000 +0200
@@ -59,8 +59,7 @@
 /* The default entry.  */
 int default_entry = 0;
 /* The fallback entry.  */
-int fallback_entryno;
-int fallback_entries[MAX_FALLBACK_ENTRIES];
+int fallback_entry = -1;
 /* The number of current entry.  */
 int current_entryno;
 /* The address for Multiboot command-line buffer.  */
@@ -98,8 +97,7 @@
 {
   default_entry = 0;
   password = 0;
-  fallback_entryno = -1;
-  fallback_entries[0] = -1;
+  fallback_entry = -1;
   grub_timeout = -1;
 }
 
@@ -1145,35 +1143,9 @@
 static int
 fallback_func (char *arg, int flags)
 {
-  int i = 0;
-
-  while (*arg)
-    {
-      int entry;
-      int j;
-      
-      if (! safe_parse_maxint (&arg, &entry))
-	return 1;
-
-      /* Remove duplications to prevent infinite looping.  */
-      for (j = 0; j < i; j++)
-	if (entry == fallback_entries[j])
-	  break;
-      if (j != i)
-	continue;
-      
-      fallback_entries[i++] = entry;
-      if (i == MAX_FALLBACK_ENTRIES)
-	break;
-      
-      arg = skip_to (0, arg);
-    }
-
-  if (i < MAX_FALLBACK_ENTRIES)
-    fallback_entries[i] = -1;
+  if (! safe_parse_maxint (&arg, &fallback_entry))
+    return 1;
 
-  fallback_entryno = (i == 0) ? -1 : 0;
-  
   return 0;
 }
 
@@ -1183,7 +1155,7 @@
   fallback_func,
   BUILTIN_MENU,
 #if 0
-  "fallback NUM...",
+  "fallback NUM",
   "Go into unattended boot mode: if the default boot entry has any"
   " errors, instead of waiting for the user to do anything, it"
   " immediately starts over using the NUM entry (same numbering as the"
@@ -3213,29 +3185,8 @@
 savedefault_func (char *arg, int flags)
 {
 #if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL)
-  unsigned long tmp_drive = saved_drive;
-  unsigned long tmp_partition = saved_partition;
-  char *default_file = (char *) DEFAULT_FILE_BUF;
-  char buf[10];
-  char sect[SECTOR_SIZE];
-  int entryno;
-  int sector_count = 0;
-  int saved_sectors[2];
-  int saved_offsets[2];
-  int saved_lengths[2];
-
-  /* Save sector information about at most two sectors.  */
-  auto void disk_read_savesect_func (int sector, int offset, int length);
-  void disk_read_savesect_func (int sector, int offset, int length)
-    {
-      if (sector_count < 2)
-	{
-	  saved_sectors[sector_count] = sector;
-	  saved_offsets[sector_count] = offset;
-	  saved_lengths[sector_count] = length;
-	}
-      sector_count++;
-    }
+  char buffer[512];
+  int *entryno_ptr;
   
   /* This command is only useful when you boot an entry from the menu
      interface.  */
@@ -3244,110 +3195,46 @@
       errnum = ERR_UNRECOGNIZED;
       return 1;
     }
+  
+  /* Get the geometry of the boot drive (i.e. the disk which contains
+     this stage2).  */
+  if (get_diskinfo (boot_drive, &buf_geom))
+    {
+      errnum = ERR_NO_DISK;
+      return 1;
+    }
 
-  /* Determine a saved entry number.  */
-  if (*arg)
+  /* Load the second sector of this stage2.  */
+  if (! rawread (boot_drive, install_second_sector, 0, SECTOR_SIZE, buffer))
     {
-      if (grub_memcmp (arg, "fallback", sizeof ("fallback") - 1) == 0)
-	{
-	  int i;
-	  int index = 0;
-	  
-	  for (i = 0; i < MAX_FALLBACK_ENTRIES; i++)
-	    {
-	      if (fallback_entries[i] < 0)
-		break;
-	      if (fallback_entries[i] == current_entryno)
-		{
-		  index = i + 1;
-		  break;
-		}
-	    }
-	  
-	  if (index >= MAX_FALLBACK_ENTRIES || fallback_entries[index] < 0)
-	    {
-	      /* This is the last.  */
-	      errnum = ERR_BAD_ARGUMENT;
-	      return 1;
-	    }
+      return 1;
+    }
 
-	  entryno = fallback_entries[index];
-	}
-      else if (! safe_parse_maxint (&arg, &entryno))
-	return 1;
+  /* Sanity check.  */
+  if (buffer[STAGE2_STAGE2_ID] != STAGE2_ID_STAGE2
+      || *((short *) (buffer + STAGE2_VER_MAJ_OFFS)) != COMPAT_VERSION)
+    {
+      errnum = ERR_BAD_VERSION;
+      return 1;
     }
-  else
-    entryno = current_entryno;
+  
+  entryno_ptr = (int *) (buffer + STAGE2_SAVED_ENTRYNO);
 
-  /* Open the default file.  */
-  saved_drive = boot_drive;
-  saved_partition = install_partition;
-  if (grub_open (default_file))
-    {
-      int len;
-      
-      disk_read_hook = disk_read_savesect_func;
-      len = grub_read (buf, sizeof (buf));
-      disk_read_hook = 0;
-      grub_close ();
+  /* Check if the saved entry number differs from current entry number.  */
+  if (*entryno_ptr != current_entryno)
+    {
+      /* Overwrite the saved entry number.  */
+      *entryno_ptr = current_entryno;
       
-      if (len != sizeof (buf))
-	{
-	  /* This is too small. Do not modify the file manually, please!  */
-	  errnum = ERR_READ;
-	  goto fail;
-	}
-
-      if (sector_count > 2)
-	{
-	  /* Is this possible?! Too fragmented!  */
-	  errnum = ERR_FSYS_CORRUPT;
-	  goto fail;
-	}
+      /* Save the image in the disk.  */
+      if (! rawwrite (boot_drive, install_second_sector, buffer))
+	return 1;
       
-      /* Set up a string to be written.  */
-      grub_memset (buf, '\n', sizeof (buf));
-      grub_sprintf (buf, "%d", entryno);
-      
-      if (saved_lengths[0] < sizeof (buf))
-	{
-	  /* The file is anchored to another file and the first few bytes
-	     are spanned in two sectors. Uggh...  */
-	  if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
-			 sect))
-	    goto fail;
-	  grub_memmove (sect + saved_offsets[0], buf, saved_lengths[0]);
-	  if (! rawwrite (current_drive, saved_sectors[0], sect))
-	    goto fail;
-
-	  if (! rawread (current_drive, saved_sectors[1], 0, SECTOR_SIZE,
-			 sect))
-	    goto fail;
-	  grub_memmove (sect + saved_offsets[1],
-			buf + saved_lengths[0],
-			sizeof (buf) - saved_lengths[0]);
-	  if (! rawwrite (current_drive, saved_sectors[1], sect))
-	    goto fail;
-	}
-      else
-	{
-	  /* This is a simple case. It fits into a single sector.  */
-	  if (! rawread (current_drive, saved_sectors[0], 0, SECTOR_SIZE,
-			 sect))
-	    goto fail;
-	  grub_memmove (sect + saved_offsets[0], buf, sizeof (buf));
-	  if (! rawwrite (current_drive, saved_sectors[0], sect))
-	    goto fail;
-	}
-
       /* Clear the cache.  */
       buf_track = -1;
     }
 
- fail:
-  saved_drive = tmp_drive;
-  saved_partition = tmp_partition;
-  return errnum;
+  return 0;
 #else /* ! SUPPORT_DISKLESS && ! GRUB_UTIL */
   errnum = ERR_UNRECOGNIZED;
   return 1;
@@ -3359,10 +3246,8 @@
   "savedefault",
   savedefault_func,
   BUILTIN_CMDLINE,
-  "savedefault [NUM | `fallback']",
-  "Save the current entry as the default boot entry if no argument is"
-  " specified. If a number is specified, this number is saved. If"
-  " `fallback' is used, next fallback entry is saved."
+  "savedefault",
+  "Save the current entry as the default boot entry."
 };
 
 
diff -ur grub.new/stage2/cmdline.c grub/stage2/cmdline.c
--- grub.new/stage2/cmdline.c	2004-06-20 15:48:46.000000000 +0200
+++ grub/stage2/cmdline.c	2004-03-27 18:02:54.000000000 +0100
@@ -201,7 +201,7 @@
 
 	  /* If a fallback entry is defined, don't prompt a user's
 	     intervention.  */
-	  if (fallback_entryno >= 0)
+	  if (fallback_entry < 0)
 	    {
 	      grub_printf ("\nPress any key to continue...");
 	      (void) getkey ();
diff -ur grub.new/stage2/shared.h grub/stage2/shared.h
--- grub.new/stage2/shared.h	2004-06-20 15:48:47.000000000 +0200
+++ grub/stage2/shared.h	2004-05-14 22:16:55.000000000 +0200
@@ -97,12 +97,8 @@
 #define PASSWORD_BUF		RAW_ADDR (0x78000)
 #define PASSWORD_BUFLEN		0x200
 
-/* THe buffer for the filename of "/boot/grub/default".  */
-#define DEFAULT_FILE_BUF	(PASSWORD_BUF + PASSWORD_BUFLEN)
-#define DEFAULT_FILE_BUFLEN	0x60
-
 /* The buffer for the command-line.  */
-#define CMDLINE_BUF		(DEFAULT_FILE_BUF + DEFAULT_FILE_BUFLEN)
+#define CMDLINE_BUF		(PASSWORD_BUF + PASSWORD_BUFLEN)
 #define CMDLINE_BUFLEN		MAX_CMDLINE
 
 /* The kill buffer for the command-line.  */
@@ -124,7 +120,7 @@
 
 /* The buffer for the menu entries.  */
 #define MENU_BUF		(UNIQUE_BUF + UNIQUE_BUFLEN)
-#define MENU_BUFLEN		(0x8000 + PASSWORD_BUF - MENU_BUF)
+#define MENU_BUFLEN		(0x8000 + PASSWORD_BUF - UNIQUE_BUF)
 
 /* The size of the drive map.  */
 #define DRIVE_MAP_SIZE		8
@@ -589,9 +585,7 @@
 
 #ifndef STAGE1_5
 /* GUI interface variables. */
-# define MAX_FALLBACK_ENTRIES	8
-extern int fallback_entries[MAX_FALLBACK_ENTRIES];
-extern int fallback_entryno;
+extern int fallback_entry;
 extern int default_entry;
 extern int current_entryno;
 
diff -ur grub.new/stage2/stage2.c grub/stage2/stage2.c
--- grub.new/stage2/stage2.c	2004-06-20 15:48:47.000000000 +0200
+++ grub/stage2/stage2.c	2004-03-27 18:02:54.000000000 +0100
@@ -390,7 +390,7 @@
 		gotoxy (3, 22);
 	      printf ("                                                                    ");
 	      grub_timeout = -1;
-	      fallback_entryno = -1;
+	      fallback_entry = -1;
 	      if (! (current_term->flags & TERM_DUMB))
 		gotoxy (74, 4 + entryno);
 	    }
@@ -731,18 +731,15 @@
       
       if (run_script (cur_entry, heap))
 	{
-	  if (fallback_entryno >= 0)
+	  if (fallback_entry < 0)
+	    break;
+	  else
 	    {
 	      cur_entry = NULL;
 	      first_entry = 0;
-	      entryno = fallback_entries[fallback_entryno];
-	      fallback_entryno++;
-	      if (fallback_entryno >= MAX_FALLBACK_ENTRIES
-		  || fallback_entries[fallback_entryno] < 0)
-		fallback_entryno = -1;
+	      entryno = fallback_entry;
+	      fallback_entry = -1;
 	    }
-	  else
-	    break;
 	}
       else
 	break;
@@ -847,7 +844,7 @@
       menu_entries = (char *) MENU_BUF;
       init_config ();
     }
-  
+      
   /* Initialize the environment for restarting Stage 2.  */
   grub_setjmp (restart_env);
   
@@ -867,36 +864,6 @@
       if (use_config_file)
 #endif /* GRUB_UTIL */
 	{
-	  char *default_file = (char *) DEFAULT_FILE_BUF;
-	  int i;
-	  
-	  /* Get a saved default entry if possible.  */
-	  saved_entryno = 0;
-	  grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN);
-	  for (i = grub_strlen(default_file); i >= 0; i--)
-	    if (default_file[i] == '/')
-	      {
-		i++;
-		break;
-	      }
-	  grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i);
-	  if (grub_open (default_file))
-	    {
-	      char buf[10]; /* This is good enough.  */
-	      char *p = buf;
-	      int len;
-	      
-	      len = grub_read (buf, sizeof (buf));
-	      if (len > 0)
-		{
-		  buf[sizeof (buf) - 1] = 0;
-		  safe_parse_maxint (&p, &saved_entryno);
-		}
-
-	      grub_close ();
-	    }
-	  errnum = ERR_NONE;
-	  
 	  do
 	    {
 	      /* STATE 0:  Before any title command.
@@ -1002,42 +969,16 @@
 	      grub_memmove (config_entries + config_len, menu_entries,
 			    menu_len);
 	      menu_entries = config_entries + config_len;
-
-	      /* Make sure that all fallback entries are valid.  */
-	      if (fallback_entryno >= 0)
-		{
-		  for (i = 0; i < MAX_FALLBACK_ENTRIES; i++)
-		    {
-		      if (fallback_entries[i] < 0)
-			break;
-		      if (fallback_entries[i] >= num_entries)
-			{
-			  grub_memmove (fallback_entries + i,
-					fallback_entries + i + 1,
-					((MAX_FALLBACK_ENTRIES - i - 1)
-					 * sizeof (int)));
-			  i--;
-			}
-		    }
-
-		  if (fallback_entries[0] < 0)
-		    fallback_entryno = -1;
-		}
+	      
 	      /* Check if the default entry is present. Otherwise reset
 		 it to fallback if fallback is valid, or to DEFAULT_ENTRY 
 		 if not.  */
 	      if (default_entry >= num_entries)
 		{
-		  if (fallback_entryno >= 0)
-		    {
-		      default_entry = fallback_entries[0];
-		      fallback_entryno++;
-		      if (fallback_entryno >= MAX_FALLBACK_ENTRIES
-			  || fallback_entries[fallback_entryno] < 0)
-			fallback_entryno = -1;
-		    }
-		  else
+		  if (fallback_entry < 0 || fallback_entry >= num_entries)
 		    default_entry = 0;
+		  else
+		    default_entry = fallback_entry;
 		}
 	      
 	      if (is_preset)
diff -ur grub.new/util/Makefile.am grub/util/Makefile.am
--- grub.new/util/Makefile.am	2004-06-20 15:48:47.000000000 +0200
+++ grub/util/Makefile.am	2003-10-19 19:36:30.000000000 +0200
@@ -1,6 +1,5 @@
 bin_PROGRAMS = mbchk
-sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo \
-	grub-set-default
+sbin_SCRIPTS = grub-install grub-md5-crypt grub-terminfo
 noinst_SCRIPTS = grub-image mkbimage
 
 EXTRA_DIST = mkbimage
diff -ur grub.new/util/grub-install.in grub/util/grub-install.in
--- grub.new/util/grub-install.in	2004-06-20 15:48:47.000000000 +0200
+++ grub/util/grub-install.in	2004-03-12 19:16:40.000000000 +0100
@@ -30,7 +30,6 @@
 pkgdatadir=${datadir}/${PACKAGE}/${host_cpu}-${host_vendor}
 
 grub_shell=${sbindir}/grub
-grub_set_default=${sbindir}/grub-set-default
 log_file=/tmp/grub-install.log.$$
 img_file=/tmp/grub-install.img.$$
 rootdir=
@@ -274,8 +273,8 @@
 
 # Initialize these directories here, since ROOTDIR was initialized.
 case "$host_os" in
-netbsd* | openbsd*)
-    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
+netbsd*)
+    # Because /boot is used for the boot block in NetBSD, use /grub
     # instead of /boot/grub.
     grub_prefix=/grub
     bootdir=${rootdir}
@@ -411,9 +410,6 @@
     cp -f $file ${grubdir} || exit 1
 done
 
-# Make a default file.
-${grub_set_default} --root-directory=${rootdir} default
-
 # Make sure that GRUB reads the same images as the host OS.
 test -n "$mkimg" && img_file=`$mkimg`
 test -n "$mklog" && log_file=`$mklog`
Only in grub.new/util: grub-set-default.in

