Deprecate devsw->d_bmaj entirely.

This removes support for booting current kernels with very old bootblocks.

Device driver writers: Please remove initializations for the d_bmaj
field in your cdevsw{}.
This commit is contained in:
Poul-Henning Kamp 2000-10-31 10:58:14 +00:00
parent ba72024c93
commit a16d0eb2d7
5 changed files with 5 additions and 215 deletions

View File

@ -86,10 +86,6 @@ static void configure_first __P((void *));
static void configure __P((void *));
static void configure_final __P((void *));
#if defined(FFS) && defined(FFS_ROOT)
static void setroot __P((void));
#endif
#if defined(NFS) && defined(NFS_ROOT)
static void pxe_setup_nfsdiskless(void);
#endif
@ -233,93 +229,11 @@ cpu_rootconf()
#endif
rootdevnames[0] = "nfs:";
#endif
#if defined(FFS) && defined(FFS_ROOT)
if (!rootdevnames[0])
setroot();
#endif
}
SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
u_long bootdev = 0; /* not a dev_t - encoding is different */
#if defined(FFS) && defined(FFS_ROOT)
#define FDMAJOR 2
#define FDUNITSHIFT 6
/*
* Attempt to find the device from which we were booted.
* If we can do so, and not instructed not to do so,
* set rootdevs[] and rootdevnames[] to correspond to the
* boot device(s).
*
* This code survives in order to allow the system to be
* booted from legacy environments that do not correctly
* populate the kernel environment. There are significant
* restrictions on the bootability of the system in this
* situation; it can only be mounting root from a 'da'
* 'wd' or 'fd' device, and the root filesystem must be ufs.
*/
static void
setroot()
{
int majdev, mindev, unit, slice, part;
dev_t newrootdev, dev;
char partname[2];
char *sname;
if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) {
printf("no B_DEVMAGIC (bootdev=%#lx)\n", bootdev);
return;
}
majdev = B_TYPE(bootdev);
dev = makebdev(majdev, 0);
if (devsw(dev) == NULL)
return;
unit = B_UNIT(bootdev);
slice = B_SLICE(bootdev);
if (slice == WHOLE_DISK_SLICE)
slice = COMPATIBILITY_SLICE;
if (slice < 0 || slice >= MAX_SLICES) {
printf("bad slice\n");
return;
}
/*
* XXX kludge for inconsistent unit numbering and lack of slice
* support for floppies.
*/
if (majdev == FDMAJOR) {
slice = COMPATIBILITY_SLICE;
part = RAW_PART;
mindev = unit << FDUNITSHIFT;
} else {
part = B_PARTITION(bootdev);
mindev = dkmakeminor(unit, slice, part);
}
newrootdev = makebdev(majdev, mindev);
sname = dsname(newrootdev, unit, slice, part, partname);
rootdevnames[0] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
sprintf(rootdevnames[0], "ufs:%s%s", sname, partname);
/*
* For properly dangerously dedicated disks (ones with a historical
* bogus partition table), the boot blocks will give slice = 4, but
* the kernel will only provide the compatibility slice since it
* knows that slice 4 is not a real slice. Arrange to try mounting
* the compatibility slice as root if mounting the slice passed by
* the boot blocks fails. This handles the dangerously dedicated
* case and perhaps others.
*/
if (slice == COMPATIBILITY_SLICE)
return;
slice = COMPATIBILITY_SLICE;
sname = dsname(newrootdev, unit, slice, part, partname);
rootdevnames[1] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
sprintf(rootdevnames[1], "ufs:%s%s", sname, partname);
}
#endif
#if defined(NFS) && defined(NFS_ROOT)
#include <sys/socket.h>

View File

@ -86,10 +86,6 @@ static void configure_first __P((void *));
static void configure __P((void *));
static void configure_final __P((void *));
#if defined(FFS) && defined(FFS_ROOT)
static void setroot __P((void));
#endif
#if defined(NFS) && defined(NFS_ROOT)
static void pxe_setup_nfsdiskless(void);
#endif
@ -233,93 +229,11 @@ cpu_rootconf()
#endif
rootdevnames[0] = "nfs:";
#endif
#if defined(FFS) && defined(FFS_ROOT)
if (!rootdevnames[0])
setroot();
#endif
}
SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
u_long bootdev = 0; /* not a dev_t - encoding is different */
#if defined(FFS) && defined(FFS_ROOT)
#define FDMAJOR 2
#define FDUNITSHIFT 6
/*
* Attempt to find the device from which we were booted.
* If we can do so, and not instructed not to do so,
* set rootdevs[] and rootdevnames[] to correspond to the
* boot device(s).
*
* This code survives in order to allow the system to be
* booted from legacy environments that do not correctly
* populate the kernel environment. There are significant
* restrictions on the bootability of the system in this
* situation; it can only be mounting root from a 'da'
* 'wd' or 'fd' device, and the root filesystem must be ufs.
*/
static void
setroot()
{
int majdev, mindev, unit, slice, part;
dev_t newrootdev, dev;
char partname[2];
char *sname;
if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) {
printf("no B_DEVMAGIC (bootdev=%#lx)\n", bootdev);
return;
}
majdev = B_TYPE(bootdev);
dev = makebdev(majdev, 0);
if (devsw(dev) == NULL)
return;
unit = B_UNIT(bootdev);
slice = B_SLICE(bootdev);
if (slice == WHOLE_DISK_SLICE)
slice = COMPATIBILITY_SLICE;
if (slice < 0 || slice >= MAX_SLICES) {
printf("bad slice\n");
return;
}
/*
* XXX kludge for inconsistent unit numbering and lack of slice
* support for floppies.
*/
if (majdev == FDMAJOR) {
slice = COMPATIBILITY_SLICE;
part = RAW_PART;
mindev = unit << FDUNITSHIFT;
} else {
part = B_PARTITION(bootdev);
mindev = dkmakeminor(unit, slice, part);
}
newrootdev = makebdev(majdev, mindev);
sname = dsname(newrootdev, unit, slice, part, partname);
rootdevnames[0] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
sprintf(rootdevnames[0], "ufs:%s%s", sname, partname);
/*
* For properly dangerously dedicated disks (ones with a historical
* bogus partition table), the boot blocks will give slice = 4, but
* the kernel will only provide the compatibility slice since it
* knows that slice 4 is not a real slice. Arrange to try mounting
* the compatibility slice as root if mounting the slice passed by
* the boot blocks fails. This handles the dangerously dedicated
* case and perhaps others.
*/
if (slice == COMPATIBILITY_SLICE)
return;
slice = COMPATIBILITY_SLICE;
sname = dsname(newrootdev, unit, slice, part, partname);
rootdevnames[1] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
sprintf(rootdevnames[1], "ufs:%s%s", sname, partname);
}
#endif
#if defined(NFS) && defined(NFS_ROOT)
#include <sys/socket.h>

View File

@ -49,8 +49,6 @@
struct cdevsw *cdevsw[NUMCDEVSW];
static int bmaj2cmaj[NUMCDEVSW];
MALLOC_DEFINE(M_DEVT, "dev_t", "dev_t storage");
/*
@ -94,28 +92,11 @@ cdevsw_add(struct cdevsw *newentry)
int i;
static int setup;
if (!setup) {
for (i = 0; i < NUMCDEVSW; i++)
if (!bmaj2cmaj[i])
bmaj2cmaj[i] = 254;
setup++;
}
if (newentry->d_maj < 0 || newentry->d_maj >= NUMCDEVSW) {
printf("%s: ERROR: driver has bogus cdevsw->d_maj = %d\n",
newentry->d_name, newentry->d_maj);
return (EINVAL);
}
if (newentry->d_bmaj >= NUMCDEVSW) {
printf("%s: ERROR: driver has bogus cdevsw->d_bmaj = %d\n",
newentry->d_name, newentry->d_bmaj);
return (EINVAL);
}
if (newentry->d_bmaj >= 0 && (newentry->d_flags & D_DISK) == 0) {
printf("ERROR: \"%s\" bmaj but is not a disk\n",
newentry->d_name);
return (EINVAL);
}
if (cdevsw[newentry->d_maj]) {
printf("WARNING: \"%s\" is usurping \"%s\"'s cdevsw[]\n",
@ -124,15 +105,6 @@ cdevsw_add(struct cdevsw *newentry)
cdevsw[newentry->d_maj] = newentry;
if (newentry->d_bmaj < 0)
return (0);
if (bmaj2cmaj[newentry->d_bmaj] != 254) {
printf("WARNING: \"%s\" is usurping \"%s\"'s bmaj\n",
newentry->d_name,
cdevsw[bmaj2cmaj[newentry->d_bmaj]]->d_name);
}
bmaj2cmaj[newentry->d_bmaj] = newentry->d_maj;
return (0);
}
@ -151,9 +123,6 @@ cdevsw_remove(struct cdevsw *oldentry)
cdevsw[oldentry->d_maj] = NULL;
if (oldentry->d_bmaj >= 0 && oldentry->d_bmaj < NUMCDEVSW)
bmaj2cmaj[oldentry->d_bmaj] = 254;
return 0;
}
@ -195,15 +164,6 @@ unit2minor(int unit)
return ((unit & 0xff) | ((unit << 8) & ~0xffff));
}
dev_t
makebdev(int x, int y)
{
if (x == umajor(NOUDEV) && y == uminor(NOUDEV))
Debugger("makebdev of NOUDEV");
return (makedev(bmaj2cmaj[x], y));
}
static dev_t
allocdev(void)
{
@ -289,7 +249,7 @@ udev2dev(udev_t x, int b)
case 0:
return makedev(umajor(x), uminor(x));
case 1:
return makebdev(umajor(x), uminor(x));
return (NODEV);
default:
Debugger("udev2dev(...,X)");
return NODEV;

View File

@ -192,7 +192,8 @@ struct cdevsw {
d_dump_t *d_dump;
d_psize_t *d_psize;
u_int d_flags;
int d_bmaj;
/* This following field is deprecated. Please don't initialize */
int d_XXXbmaj;
};
/*

View File

@ -192,7 +192,8 @@ struct cdevsw {
d_dump_t *d_dump;
d_psize_t *d_psize;
u_int d_flags;
int d_bmaj;
/* This following field is deprecated. Please don't initialize */
int d_XXXbmaj;
};
/*