Hello!

The current GRUB cannot write Stage2 on the "install" command.
This happens because stage2_sect is not calculated properly.

As usually, the life is not trivial :-)
Either we should introduce another debug_fs function for the first
sector of Stage2 or the existing debug_fs_blocklist_func() should
write the first sector into stage2_sect

I prefer the second solution.

The attached patch removes the "installsect" and makes
debug_fs_blocklist_func() responsible for initialization of
stage2_sect

ChangeLog:
        * stage2/builtins.c (install_func): initialize stage2_sect
        with 0. Remove installsect
        (debug_fs_blocklist_func): write the current sector into
        stage2_sect if it is 0.

Pavel Roskin
--- stage2/builtins.c   Tue Sep 21 10:41:55 1999
+++ stage2/builtins.c   Wed Sep 22 02:45:32 1999
@@ -727,7 +727,7 @@
   int write_stage2_sect = 0;
   int stage2_sect;
   char *ptr;
-  int installaddr, installlist, installsect;
+  int installaddr, installlist;
 
   /* Write SECTOR to INSTALLLIST, and update INSTALLADDR and
      INSTALLSECT.  */
@@ -752,7 +752,8 @@
        }
 
       *((unsigned short *) installlist) += 1;
-      installsect = sector;
+      if (!stage2_sect)
+       stage2_sect = sector;
       installaddr += 512;
     }
 
@@ -921,8 +922,6 @@
   *((unsigned short *) (BOOTSEC_LOCATION + STAGE1_INSTALLADDR))
     = installaddr;
   
-  stage2_sect = installsect;
-
   if (*ptr == 'p')
     {
       write_stage2_sect = 1;
@@ -946,6 +945,7 @@
   /* Read the whole of Stage 2.  */
   filepos = 0;
   debug_fs = debug_fs_blocklist_func;
+  stage2_sect = 0;
   if (! grub_read ((char *) RAW_ADDR (0x100000), -1))
     {
       debug_fs = 0;

Reply via email to