[comp.os.minix] MACMINIX: kernel fixes

archetyp@uxh.cso.uiuc.edu (Joseph R Pickert) (11/13/90)

Enclosed are fixes for kernel/{setup.c,cstart.c} and tools/macboot.c.
When booting or configuring, the CONF resource is created if one
does not exist.  The code was putting the resource in the last opened
resource file instead of the Macboot resource file.
In addition, ReleaseResource was incorrectly being called.
Many thanks to Kelvin Delbarre for pointing these problems out.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	cstart.cdif
#	macboot.cdif
#	setup.cdif
# This archive created: Mon Nov 12 21:09:48 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'cstart.cdif'
then
	echo shar: "will not over-write existing file 'cstart.cdif'"
else
cat << \SHAR_EOF > 'cstart.cdif'
*** 1.5.10/kernel/cstart.c	Thu Nov  1 09:59:22 1990
--- 1.5.10.1/kernel/cstart.c	Mon Nov 12 21:01:34 1990
***************
*** 29,34 ****
--- 29,35 ----
  PRIVATE struct romtable romversions[] ={
    {0x00, 0x75, 0x2e},			/* mac plus */
    {0x276, 0x276, 0x2e},			/* mac se */
+   {0x37A, 0x37A, 0x2e},			/* mac portable */
    {0x76, 0x67b, 0x30},			/* mac II to mac IIcx */
    {0x67c, 0x7fff, 0x32}			/* mac IIci and above */
  };
***************
*** 84,94 ****
    /* Initialize macintosh */
    FlushEvents((short)-1, (short)0);
    InitGraf((Ptr)&qd->thePort);
-   InitCursor();
    InitFonts();
    InitWindows();
-   InitMenus();
    InitDialogs(0L);
    
    /* record sizes */
    sizes[0] = kc >> CLICK_SHIFT; sizes[1] = kd >> CLICK_SHIFT;
--- 85,95 ----
    /* Initialize macintosh */
    FlushEvents((short)-1, (short)0);
    InitGraf((Ptr)&qd->thePort);
    InitFonts();
    InitWindows();
    InitDialogs(0L);
+   InitMenus();
+   InitCursor();
    
    /* record sizes */
    sizes[0] = kc >> CLICK_SHIFT; sizes[1] = kd >> CLICK_SHIFT;
SHAR_EOF
fi
if test -f 'macboot.cdif'
then
	echo shar: "will not over-write existing file 'macboot.cdif'"
else
cat << \SHAR_EOF > 'macboot.cdif'
*** 1.5.10/tools/macboot.c	Fri Aug 10 11:48:46 1990
--- 1.5.10.1/tools/macboot.c	Mon Nov 12 20:52:32 1990
***************
*** 189,194 ****
--- 189,195 ----
    qd = &qdg;
  #endif
    InitGraf((Ptr) &qd->thePort);
+   InitFonts();
    InitWindows();
    InitDialogs(0L);
    InitCursor();
SHAR_EOF
fi
if test -f 'setup.cdif'
then
	echo shar: "will not over-write existing file 'setup.cdif'"
else
cat << \SHAR_EOF > 'setup.cdif'
*** 1.5.10/kernel/setup.c	Thu Nov  1 09:59:42 1990
--- 1.5.10.1/kernel/setup.c	Mon Nov 12 20:50:37 1990
***************
*** 93,100 ****
    SFTypeList tl;
    char *p;
    EventRecord e;
  
!   if ((cr = GetResource("CONF", 128)) == 0L) {
      strcpy(cf->root, "ROOT");
      cf->heap = 200;
      cf->ram = 1;
--- 93,102 ----
    SFTypeList tl;
    char *p;
    EventRecord e;
+   extern int CurApRefNum;
+   int currentref;
  
!   if ((cr = GetNamedResource("CONF", "MINIX Configuration")) == 0L) {
      strcpy(cf->root, "ROOT");
      cf->heap = 200;
      cf->ram = 1;
***************
*** 103,111 ****
  	  HLock(cr);
  	  BlockMove(cf, *cr, (long)sizeof (struct config));
  	  HUnlock(cr);
! 	  AddResource(cr, "CONF", 128, "");
  	  WriteResource(cr);
! 	  ReleaseResource(cr);
      }
    }
    else {
--- 105,117 ----
  	  HLock(cr);
  	  BlockMove(cf, *cr, (long)sizeof (struct config));
  	  HUnlock(cr);
! 	  HNoPurge(cr);
! 	  currentref = CurResFile();
! 	  UseResFile(CurApRefNum);
! 	  AddResource(cr, "CONF", 128, "MINIX Configuration");
  	  WriteResource(cr);
! 	  HPurge(cr);
! 	  UseResFile(currentref);
      }
    }
    else {
***************
*** 209,216 ****
          HLock(cr);
          BlockMove(cf, *cr, (long)sizeof (struct config));
          HUnlock(cr);
          ChangedResource(cr);
!         ReleaseResource(cr);
      }
      else
        *cf = save;
--- 215,224 ----
          HLock(cr);
          BlockMove(cf, *cr, (long)sizeof (struct config));
          HUnlock(cr);
+ 	HNoPurge(cr);
          ChangedResource(cr);
! 	WriteResource(cr);
! 	HPurge(cr);
      }
      else
        *cf = save;
SHAR_EOF
fi
exit 0
#	End of shell archive