add a new machine-dependent sysctl, machdep.root_device, which is the
(string) name of the root device. It's a string so that it can be used before dev_mkdb has been run.
This commit is contained in:
parent
5c5c2d1804
commit
1beca2d96b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: autoconf.c,v 1.6 1996/06/13 23:10:37 cgd Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.7 1996/06/14 20:40:46 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -55,6 +55,8 @@
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/prom.h>
|
||||
|
||||
extern char root_device[17]; /* XXX */
|
||||
|
||||
struct device *booted_device;
|
||||
int booted_partition;
|
||||
struct bootdev_data *bootdev_data;
|
||||
@ -67,6 +69,7 @@ struct device *parsedisk __P((char *str, int len, int defpart, dev_t *devp));
|
||||
static struct device *getdisk __P((char *str, int len, int defpart,
|
||||
dev_t *devp));
|
||||
static int findblkmajor __P((struct device *dv));
|
||||
static char *findblkname __P((int));
|
||||
static int getstr __P((char *cp, int size));
|
||||
|
||||
/*
|
||||
@ -142,6 +145,18 @@ findblkmajor(dv)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static char *
|
||||
findblkname(maj)
|
||||
int maj;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i)
|
||||
if (maj == nam2blk[i].maj)
|
||||
return (nam2blk[i].name);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static struct device *
|
||||
getdisk(str, len, defpart, devp)
|
||||
char *str;
|
||||
@ -223,7 +238,7 @@ setroot()
|
||||
struct device *dv;
|
||||
register int len;
|
||||
dev_t nrootdev, nswapdev = NODEV;
|
||||
char buf[128];
|
||||
char buf[128], *rootdevname;
|
||||
extern int (*mountroot) __P((void *));
|
||||
dev_t temp;
|
||||
struct device *bootdv, *rootdv, *swapdv;
|
||||
@ -351,17 +366,28 @@ gotswap:
|
||||
swdevt[0].sw_dev = nswapdev;
|
||||
swdevt[1].sw_dev = NODEV;
|
||||
} else {
|
||||
|
||||
/*
|
||||
* `root DEV swap DEV': honour rootdev/swdevt.
|
||||
* rootdev/swdevt/mountroot already properly set.
|
||||
*/
|
||||
|
||||
rootdevname = findblkname(major(rootdev));
|
||||
if (rootdevname == NULL) {
|
||||
/* Root on NFS or unknown device. */
|
||||
strcpy(root_device, "??");
|
||||
} else {
|
||||
/* Root on known block device. */
|
||||
sprintf(root_device, "%s%d%c", rootdevname,
|
||||
DISKUNIT(rootdev), DISKPART(rootdev) + 'a');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (rootdv->dv_class) {
|
||||
#if defined(NFSCLIENT)
|
||||
case DV_IFNET:
|
||||
strcpy(root_device, "??");
|
||||
mountroot = nfs_mountroot;
|
||||
nfsbootdevname = rootdv->dv_xname;
|
||||
return;
|
||||
@ -369,8 +395,9 @@ gotswap:
|
||||
#if defined(FFS)
|
||||
case DV_DISK:
|
||||
mountroot = ffs_mountroot;
|
||||
printf("root on %s%c", rootdv->dv_xname,
|
||||
sprintf(root_device, "%s%c", rootdv->dv_xname,
|
||||
DISKPART(rootdev) + 'a');
|
||||
printf("root on %s", root_device);
|
||||
if (nswapdev != NODEV)
|
||||
printf(" swap on %s%c", swapdv->dv_xname,
|
||||
DISKPART(nswapdev) + 'a');
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: machdep.c,v 1.29 1996/06/13 23:16:43 cgd Exp $ */
|
||||
/* $NetBSD: machdep.c,v 1.30 1996/06/14 20:40:47 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
||||
@ -181,6 +181,9 @@ char *cpu_iobus;
|
||||
|
||||
char boot_flags[64];
|
||||
|
||||
/* for cpu_sysctl() */
|
||||
char root_device[17];
|
||||
|
||||
int
|
||||
alpha_init(pfn, ptb)
|
||||
u_long pfn; /* first free PFN number */
|
||||
@ -1211,6 +1214,10 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
|
||||
consdev = NODEV;
|
||||
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
|
||||
sizeof consdev));
|
||||
|
||||
case CPU_ROOT_DEVICE:
|
||||
return (sysctl_rdstring(oldp, oldlenp, newp, root_device));
|
||||
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cpu.h,v 1.7 1995/12/21 05:01:32 mycroft Exp $ */
|
||||
/* $NetBSD: cpu.h,v 1.8 1996/06/14 20:40:49 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
@ -115,11 +115,13 @@ extern u_int64_t ssir;
|
||||
* CTL_MACHDEP definitions.
|
||||
*/
|
||||
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
|
||||
#define CPU_MAXID 2 /* number of valid machdep ids */
|
||||
#define CPU_ROOT_DEVICE 2 /* string: root device name */
|
||||
#define CPU_MAXID 3 /* number of valid machdep ids */
|
||||
|
||||
#define CTL_MACHDEP_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "console_device", CTLTYPE_STRUCT }, \
|
||||
{ "root_device", CTLTYPE_STRING }, \
|
||||
}
|
||||
|
||||
#endif /* _ALPHA_CPU_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user