Major lobotomy of config(8). The

config kernel mumble mumble

line has been obsoleted and removed and with it went all knowledge of
devices on the part of config.

You can still configure a root device (which is used if you give
the "-r" flag) but now with an option:

        options         ROOTDEVNAME=\"da0s2e\"

The string is parsed by the same code as at the "boot -a" prompt.

At the same time, make the "boot -a" prompt both more able and more
informative.

ALPHA/PC98 people:  You will have to adapt a few simple changes
(defining rootdev and dumpdev somewhere else) before config works
for you again, sorry, but it's all in the name of progress.
This commit is contained in:
Poul-Henning Kamp 1999-05-09 16:46:01 +00:00
parent b6dc33dbf2
commit b307e58fc7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=46806
13 changed files with 277 additions and 51 deletions

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.117 1999/05/08 06:39:18 phk Exp $
* $Id: autoconf.c,v 1.118 1999/05/09 07:56:36 phk Exp $
*/
/*
@ -51,6 +51,7 @@
#include "opt_mfs.h"
#include "opt_nfsroot.h"
#include "opt_bus.h"
#include "opt_rootdevname.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -103,6 +104,8 @@ static void configure_finish __P((void));
static void configure_start __P((void));
static int setdumpdev __P((dev_t dev));
static void setroot __P((void));
static int setrootbyname __P((char *name));
static void gets __P((char *));
SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
/* SI_ORDER_SECOND is hookable */
@ -110,6 +113,8 @@ SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
/* SI_ORDER_MIDDLE is hookable */
SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
dev_t rootdev = NODEV;
dev_t dumpdev = NODEV;
#if defined(CD9660) || defined(CD9660_ROOT)
@ -431,7 +436,11 @@ setroot()
char partname[2];
char *sname;
if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != B_DEVMAGIC)
if (boothowto & RB_DFLTROOT) {
setrootbyname(ROOTDEVNAME);
return;
}
if ((bootdev & B_MAGICMASK) != B_DEVMAGIC)
return;
majdev = B_TYPE(bootdev);
dev = makedev(majdev, 0);
@ -497,3 +506,118 @@ sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
static int
setrootbyname(char *name)
{
char *cp;
int bd, unit, slice, part;
dev_t dev;
slice = 0;
part = 0;
cp = name;
while (cp != '\0' && (*cp < '0' || *cp > '9'))
cp++;
if (cp == name) {
printf("missing device name\n");
return(1);
}
if (*cp == '\0') {
printf("missing unit number\n");
return(1);
}
unit = *cp - '0';
*cp++ = '\0';
for (bd = 0; bd < nblkdev; bd++) {
dev = makedev(bd, 0);
if (bdevsw(dev) != NULL &&
strcmp(bdevsw(dev)->d_name, name) == 0)
goto gotit;
}
return (2);
gotit:
while (*cp >= '0' && *cp <= '9')
unit += 10 * unit + *cp++ - '0';
if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
slice = cp[1] - '0';
cp += 2;
}
if (*cp >= 'a' && *cp <= 'h') {
part = *cp - 'a';
cp++;
}
if (*cp != '\0') {
printf("junk after name\n");
return (1);
}
printf("driver=%s, unit=%d, slice=%d, part=%d\n",
name, unit, slice, part);
rootdev = makedev(bd, dkmakeminor(unit, slice, part));
return 0;
}
void
setconf()
{
char name[128];
int i;
dev_t dev;
for(;;) {
printf("root device? ");
gets(name);
i = setrootbyname(name);
if (!i)
return;
printf("use one of:\n");
for (i = 0; i < nblkdev; i++) {
dev = makedev(i, 0);
if (bdevsw(dev) != NULL)
printf(" %s", bdevsw(dev)->d_name);
}
printf(" followed by a unit number...\n");
}
}
static void
gets(cp)
char *cp;
{
register char *lp;
register int c;
lp = cp;
for (;;) {
printf("%c", c = cngetc() & 0177);
switch (c) {
case -1:
case '\n':
case '\r':
*lp++ = '\0';
return;
case '\b':
case '\177':
if (lp > cp) {
printf(" \b");
lp--;
}
continue;
case '#':
lp--;
if (lp < cp)
lp = cp;
continue;
case '@':
case 'u' & 037:
lp = cp;
printf("%c", '\n');
continue;
default:
*lp++ = c;
}
}
}

View File

@ -11,7 +11,7 @@
# device lines is present in the ./LINT configuration file. If you are
# in doubt as to the purpose or necessity of a line, check first in LINT.
#
# $Id: GENERIC,v 1.167 1999/05/02 21:54:02 n_hibma Exp $
# $Id: GENERIC,v 1.168 1999/05/04 00:15:15 msmith Exp $
machine i386
cpu I386_CPU
@ -42,8 +42,6 @@ options FAILSAFE #Be conservative
options USERCONFIG #boot -c editor
options VISUAL_USERCONFIG #visual boot -c editor
config kernel root on wd0
# To make an SMP kernel, the next two are needed
#options SMP # Symmetric MultiProcessor Kernel
#options APIC_IO # Symmetric (APIC) I/O

View File

@ -1,7 +1,7 @@
# Makefile.i386 -- with config changes.
# Copyright 1990 W. Jolitz
# from: @(#)Makefile.i386 7.1 5/10/91
# $Id: Makefile.i386,v 1.148 1999/04/24 21:38:50 peter Exp $
# $Id: Makefile.i386,v 1.149 1999/05/08 20:04:39 peter Exp $
#
# Makefile for FreeBSD
#
@ -17,7 +17,7 @@
#
# Which version of config(8) is required.
%VERSREQ= 400014
%VERSREQ= 400015
KERNFORMAT?= elf

View File

@ -1,7 +1,7 @@
# Makefile.i386 -- with config changes.
# Copyright 1990 W. Jolitz
# from: @(#)Makefile.i386 7.1 5/10/91
# $Id: Makefile.i386,v 1.148 1999/04/24 21:38:50 peter Exp $
# $Id: Makefile.i386,v 1.149 1999/05/08 20:04:39 peter Exp $
#
# Makefile for FreeBSD
#
@ -17,7 +17,7 @@
#
# Which version of config(8) is required.
%VERSREQ= 400014
%VERSREQ= 400015
KERNFORMAT?= elf

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.593 1999/05/05 12:22:31 jb Exp $
# $Id: LINT,v 1.594 1999/05/06 18:08:23 peter Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -67,15 +67,6 @@ options PQ_LARGECACHE # color for 512k/16k cache
#
options INCLUDE_CONFIG_FILE # Include this file in kernel
#
# This directive defines a number of things:
# - The compiled kernel is to be called `kernel'
# - The root filesystem might be on partition wd0a
# - Crash dumps will be written to wd0b, if possible. Specifying the
# dump device here is not recommended. Use dumpon(8).
#
config kernel root on wd0 dumps on wd0
#####################################################################
# SMP OPTIONS:
@ -351,6 +342,9 @@ options UCONSOLE
options USERCONFIG #boot -c editor
options INTRO_USERCONFIG #imply -c and show intro screen
options VISUAL_USERCONFIG #visual boot -c editor
# XXX - neither does this
options ROOTDEVNAME=\"da0s2e\"
#####################################################################
# NETWORKING OPTIONS

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.237 1999/05/05 07:36:55 wpaul Exp $
# $Id: files.i386,v 1.238 1999/05/08 15:46:46 peter Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@ -97,7 +97,6 @@ i386/i386/pmap.c standard
i386/i386/procfs_machdep.c standard
i386/i386/simplelock.s optional smp
i386/i386/support.s standard
i386/i386/swapgeneric.c standard
i386/i386/swtch.s standard
i386/i386/sys_machdep.c standard
i386/i386/trap.c standard

View File

@ -1,4 +1,4 @@
# $Id: options,v 1.135 1999/05/05 11:24:15 jb Exp $
# $Id: options,v 1.136 1999/05/09 13:10:41 peter Exp $
#
# On the handling of kernel options
#
@ -363,3 +363,5 @@ VINUMDEBUG opt_vinum.h
# Embedded system options
INIT_PATH opt_init_path.h
ROOTDEVNAME opt_rootdevname.h

View File

@ -11,7 +11,7 @@
# device lines is present in the ./LINT configuration file. If you are
# in doubt as to the purpose or necessity of a line, check first in LINT.
#
# $Id: GENERIC,v 1.167 1999/05/02 21:54:02 n_hibma Exp $
# $Id: GENERIC,v 1.168 1999/05/04 00:15:15 msmith Exp $
machine i386
cpu I386_CPU
@ -42,8 +42,6 @@ options FAILSAFE #Be conservative
options USERCONFIG #boot -c editor
options VISUAL_USERCONFIG #visual boot -c editor
config kernel root on wd0
# To make an SMP kernel, the next two are needed
#options SMP # Symmetric MultiProcessor Kernel
#options APIC_IO # Symmetric (APIC) I/O

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.593 1999/05/05 12:22:31 jb Exp $
# $Id: LINT,v 1.594 1999/05/06 18:08:23 peter Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -67,15 +67,6 @@ options PQ_LARGECACHE # color for 512k/16k cache
#
options INCLUDE_CONFIG_FILE # Include this file in kernel
#
# This directive defines a number of things:
# - The compiled kernel is to be called `kernel'
# - The root filesystem might be on partition wd0a
# - Crash dumps will be written to wd0b, if possible. Specifying the
# dump device here is not recommended. Use dumpon(8).
#
config kernel root on wd0 dumps on wd0
#####################################################################
# SMP OPTIONS:
@ -351,6 +342,9 @@ options UCONSOLE
options USERCONFIG #boot -c editor
options INTRO_USERCONFIG #imply -c and show intro screen
options VISUAL_USERCONFIG #visual boot -c editor
# XXX - neither does this
options ROOTDEVNAME=\"da0s2e\"
#####################################################################
# NETWORKING OPTIONS

View File

@ -1,7 +1,7 @@
# Makefile.i386 -- with config changes.
# Copyright 1990 W. Jolitz
# from: @(#)Makefile.i386 7.1 5/10/91
# $Id: Makefile.i386,v 1.148 1999/04/24 21:38:50 peter Exp $
# $Id: Makefile.i386,v 1.149 1999/05/08 20:04:39 peter Exp $
#
# Makefile for FreeBSD
#
@ -17,7 +17,7 @@
#
# Which version of config(8) is required.
%VERSREQ= 400014
%VERSREQ= 400015
KERNFORMAT?= elf

View File

@ -2,7 +2,7 @@
# LINT -- config file for checking all the sources, tries to pull in
# as much of the source tree as it can.
#
# $Id: LINT,v 1.593 1999/05/05 12:22:31 jb Exp $
# $Id: LINT,v 1.594 1999/05/06 18:08:23 peter Exp $
#
# NB: You probably don't want to try running a kernel built from this
# file. Instead, you should start from GENERIC, and add options from
@ -67,15 +67,6 @@ options PQ_LARGECACHE # color for 512k/16k cache
#
options INCLUDE_CONFIG_FILE # Include this file in kernel
#
# This directive defines a number of things:
# - The compiled kernel is to be called `kernel'
# - The root filesystem might be on partition wd0a
# - Crash dumps will be written to wd0b, if possible. Specifying the
# dump device here is not recommended. Use dumpon(8).
#
config kernel root on wd0 dumps on wd0
#####################################################################
# SMP OPTIONS:
@ -351,6 +342,9 @@ options UCONSOLE
options USERCONFIG #boot -c editor
options INTRO_USERCONFIG #imply -c and show intro screen
options VISUAL_USERCONFIG #visual boot -c editor
# XXX - neither does this
options ROOTDEVNAME=\"da0s2e\"
#####################################################################
# NETWORKING OPTIONS

View File

@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
# $Id: files.i386,v 1.237 1999/05/05 07:36:55 wpaul Exp $
# $Id: files.i386,v 1.238 1999/05/08 15:46:46 peter Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@ -97,7 +97,6 @@ i386/i386/pmap.c standard
i386/i386/procfs_machdep.c standard
i386/i386/simplelock.s optional smp
i386/i386/support.s standard
i386/i386/swapgeneric.c standard
i386/i386/swtch.s standard
i386/i386/sys_machdep.c standard
i386/i386/trap.c standard

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
* $Id: autoconf.c,v 1.117 1999/05/08 06:39:18 phk Exp $
* $Id: autoconf.c,v 1.118 1999/05/09 07:56:36 phk Exp $
*/
/*
@ -51,6 +51,7 @@
#include "opt_mfs.h"
#include "opt_nfsroot.h"
#include "opt_bus.h"
#include "opt_rootdevname.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -103,6 +104,8 @@ static void configure_finish __P((void));
static void configure_start __P((void));
static int setdumpdev __P((dev_t dev));
static void setroot __P((void));
static int setrootbyname __P((char *name));
static void gets __P((char *));
SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
/* SI_ORDER_SECOND is hookable */
@ -110,6 +113,8 @@ SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
/* SI_ORDER_MIDDLE is hookable */
SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
dev_t rootdev = NODEV;
dev_t dumpdev = NODEV;
#if defined(CD9660) || defined(CD9660_ROOT)
@ -431,7 +436,11 @@ setroot()
char partname[2];
char *sname;
if (boothowto & RB_DFLTROOT || (bootdev & B_MAGICMASK) != B_DEVMAGIC)
if (boothowto & RB_DFLTROOT) {
setrootbyname(ROOTDEVNAME);
return;
}
if ((bootdev & B_MAGICMASK) != B_DEVMAGIC)
return;
majdev = B_TYPE(bootdev);
dev = makedev(majdev, 0);
@ -497,3 +506,118 @@ sysctl_kern_dumpdev SYSCTL_HANDLER_ARGS
SYSCTL_PROC(_kern, KERN_DUMPDEV, dumpdev, CTLTYPE_OPAQUE|CTLFLAG_RW,
0, sizeof dumpdev, sysctl_kern_dumpdev, "T,dev_t", "");
static int
setrootbyname(char *name)
{
char *cp;
int bd, unit, slice, part;
dev_t dev;
slice = 0;
part = 0;
cp = name;
while (cp != '\0' && (*cp < '0' || *cp > '9'))
cp++;
if (cp == name) {
printf("missing device name\n");
return(1);
}
if (*cp == '\0') {
printf("missing unit number\n");
return(1);
}
unit = *cp - '0';
*cp++ = '\0';
for (bd = 0; bd < nblkdev; bd++) {
dev = makedev(bd, 0);
if (bdevsw(dev) != NULL &&
strcmp(bdevsw(dev)->d_name, name) == 0)
goto gotit;
}
return (2);
gotit:
while (*cp >= '0' && *cp <= '9')
unit += 10 * unit + *cp++ - '0';
if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
slice = cp[1] - '0';
cp += 2;
}
if (*cp >= 'a' && *cp <= 'h') {
part = *cp - 'a';
cp++;
}
if (*cp != '\0') {
printf("junk after name\n");
return (1);
}
printf("driver=%s, unit=%d, slice=%d, part=%d\n",
name, unit, slice, part);
rootdev = makedev(bd, dkmakeminor(unit, slice, part));
return 0;
}
void
setconf()
{
char name[128];
int i;
dev_t dev;
for(;;) {
printf("root device? ");
gets(name);
i = setrootbyname(name);
if (!i)
return;
printf("use one of:\n");
for (i = 0; i < nblkdev; i++) {
dev = makedev(i, 0);
if (bdevsw(dev) != NULL)
printf(" %s", bdevsw(dev)->d_name);
}
printf(" followed by a unit number...\n");
}
}
static void
gets(cp)
char *cp;
{
register char *lp;
register int c;
lp = cp;
for (;;) {
printf("%c", c = cngetc() & 0177);
switch (c) {
case -1:
case '\n':
case '\r':
*lp++ = '\0';
return;
case '\b':
case '\177':
if (lp > cp) {
printf(" \b");
lp--;
}
continue;
case '#':
lp--;
if (lp < cp)
lp = cp;
continue;
case '@':
case 'u' & 037:
lp = cp;
printf("%c", '\n');
continue;
default:
*lp++ = c;
}
}
}