Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 1998 06:52:35 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        jkh@time.cdrom.com, mike@smith.net.au
Cc:        cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-release@FreeBSD.ORG, jkh@FreeBSD.ORG
Subject:   Re: cvs commit: src/release/sysinstall devices.c floppy.c install.c menus.c
Message-ID:  <199802111952.GAA09971@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>From: "Jordan K. Hubbard" <jkh@time.cdrom.com>
>Sender: owner-cvs-committers@FreeBSD.ORG
>Precedence: bulk
>X-Loop: FreeBSD.ORG
>Status: R
>
>> >   MFC: create devices only as needed.  Gosh I sure wish those "extra" 56
>> >   bytes in the boot blocks could be used to TEACH THE BOOT BLOCKS ABOUT 
>> >   SLICES SO WE COULD GET RID OF THE %$#@*!! ROOT COMPATABILITY HACK.  
>> >   While I'm wishing, I'd like world peace too.
>> 
>> You want the bootblocks to know which slice they're loaded from, right?

I don't think so.  They've done this since rev.1.28 (1994/12/18) of
bisoboot/boot.c.  The unfinished details are that the bootblocks
can't parse slice numbers in device names (e.g., "wd(0,s2,a)"),
the kernel ignores the slice number passed by the boot blocks, and
nothing related to booting understands extended partitions.

Here is code to handle the slice number passed by the boot blocks.
I've used it for more than 3 years (except for the part to actually
use the slice number), but never committed it because it depends on
uniform minor numbering for all bootable devices.  Floppies and
cdroms have non-uniform minor numbering in -current.  I use slice-
aware floppy driver, but it is not suitable for general use so I
never committed it (the combination of no partition table with an
an 0xAA55 signature always causes problems, and is normal for boot
floppies).

This code also has a hack to override the boot device passed by
the boot blocks.  I don't use it.

diff -c2 autoconf.c~ autoconf.c
*** autoconf.c~	Sat Jan 31 17:26:14 1998
--- autoconf.c	Sat Jan 31 17:26:17 1998
***************
*** 56,59 ****
--- 56,60 ----
  #include <sys/conf.h>
  #include <sys/disklabel.h>
+ #include <sys/diskslice.h>
  #include <sys/reboot.h>
  #include <sys/kernel.h>
***************
*** 431,439 ****
  };
  
- #define	PARTITIONMASK	0x7
- #define	PARTITIONSHIFT	3
- #define FDUNITSHIFT     6
- #define RAW_PART        2
- 
  /*
   * Attempt to find the device from which we were booted.
--- 434,437 ----
***************
*** 444,479 ****
  setroot()
  {
! 	int  majdev, mindev, unit, part, adaptor;
! 	dev_t orootdev;
! 
! /*printf("howto %x bootdev %x ", boothowto, bootdev);*/
! 	if (boothowto & RB_DFLTROOT ||
! 	    (bootdev & B_MAGICMASK) != (u_long)B_DEVMAGIC)
  		return;
! 	majdev = (bootdev >> B_TYPESHIFT) & B_TYPEMASK;
  	if (majdev > sizeof(devname) / sizeof(devname[0]))
  		return;
! 	adaptor = (bootdev >> B_ADAPTORSHIFT) & B_ADAPTORMASK;
! 	unit = (bootdev >> B_UNITSHIFT) & B_UNITMASK;
! 	if (majdev == FDMAJOR) {
! 		part = RAW_PART;
! 		mindev = unit << FDUNITSHIFT;
! 	}
! 	else {
! 		part = (bootdev >> B_PARTITIONSHIFT) & B_PARTITIONMASK;
! 		mindev = (unit << PARTITIONSHIFT) + part;
! 	}
! 	orootdev = rootdev;
! 	rootdev = makedev(majdev, mindev);
! 	/*
! 	 * If the original rootdev is the same as the one
! 	 * just calculated, don't need to adjust the swap configuration.
! 	 */
! 	if (rootdev == orootdev)
  		return;
! 	printf("changing root device to %c%c%d%c\n",
! 		devname[majdev][0], devname[majdev][1],
! 		mindev >> (majdev == FDMAJOR ? FDUNITSHIFT : PARTITIONSHIFT),
! 		part + 'a');
  }
  
--- 442,481 ----
  setroot()
  {
! 	int majdev, mindev, adaptor, controller, unit, slice, part;
! 	dev_t newrootdev;
! 	char partname[2];
! 	char *sname;
! 	struct isa_device *idp;
! 
! #include "npx.h"
! #if NNPX > 0
! 	idp = find_isadev(isa_devtab_null, &npxdriver, 0);
! 	if (idp != NULL && idp->id_maddr != 0)
! 		bootdev = (u_long)idp->id_maddr;
! #endif
! 	if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != B_DEVMAGIC)
  		return;
! 	majdev = B_TYPE(bootdev);
  	if (majdev > sizeof(devname) / sizeof(devname[0]))
  		return;
! 	adaptor = B_ADAPTOR(bootdev);
! 	controller = B_CONTROLLER(bootdev);
! 	unit = B_UNIT(bootdev);
! #if 0 /* not yet */
! 	slice = (adaptor << 4) | controller;	/* XXX */
! #else
! 	slice = COMPATIBILITY_SLICE;
! #endif
! 	part = B_PARTITION(bootdev);
! 	if (majdev == FDMAJOR && slice == COMPATIBILITY_SLICE)
! 		part = RAW_PART;	/* XXX */
! 	mindev = dkmakeminor(unit, slice, part);
! 	newrootdev = makedev(majdev, mindev);
! 	if (newrootdev == rootdev)
  		return;
! 	rootdev = newrootdev;
! 	sname = dsname("", unit, slice, part, partname);
! 	printf("changing root device to %c%c%s%s\n",
! 		devname[majdev][0], devname[majdev][1], sname, partname);
  }
  
>> I can do this, but it will mean that anyone wanting to boot a 2.2.6+ 
>> kernel *must* update their bootblocks.
>
>Why?  If they have the old boot blocks then all that should be
>required is that they have root on "/dev/wd0a" instead of
>"/dev/wd0s2a", or whatever, which is something that'll be the case
>anyway if they upgraded since their /etc/fstab file will have been
>preserved.

They already have suitable boot blocks (unless they are upgrading from
a release before 2.0.5 :-).  However, if the kernel actually uses the
slice number passed by the boot blocks, then it will think that root
is on "/dev/wd0s2a", or whatever, and old fstabs that say it is on
"/dev/wd0a" won't work.  ISTR that it was difficult to even mount "/"
read-write where the kernel thinks it is so that you can edit fstab.
Now I remember - I would boot from /dev/fds4a and find that I had
no device node for this device, and no way to create one because "/"
was mounted read-only and there were no other mountable devices.

Bruce

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802111952.GAA09971>