diff options
author | green <green@FreeBSD.org> | 2000-03-20 16:28:35 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2000-03-20 16:28:35 +0000 |
commit | 8d6ef7262607df09489a4257d8bc914b7dfaec05 (patch) | |
tree | 76657f40651196206554d5cde83f68b328ab40b0 /sys/kern/vfs_conf.c | |
parent | 5802589ba8a4501696e3241529b0cfdd5011d0fc (diff) | |
download | FreeBSD-src-8d6ef7262607df09489a4257d8bc914b7dfaec05.zip FreeBSD-src-8d6ef7262607df09489a4257d8bc914b7dfaec05.tar.gz |
Split the logic of
static int setrootbyname(char *name);
out into
dev_t getdiskbyname(char *name);
This makes it easy to create a new DDB command, which is the big reason
for the change. You can now do the following in DDB:
Example rc.conf entry:
dumpdev="/dev/ad0s1b" # Device name to crashdump to (if enabled).
db> show disk/ad0s1b
dev_t = 0xc0b7ea00
db> p *dumpdev
c0b7ea00
Diffstat (limited to 'sys/kern/vfs_conf.c')
-rw-r--r-- | sys/kern/vfs_conf.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index 8aaa482..e2c67e2 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -55,6 +55,11 @@ #include <sys/conf.h> #include <sys/cons.h> +#include "opt_ddb.h" +#ifdef DDB +#include <ddb/ddb.h> +#endif + MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure"); #define ROOTNAME "root_device" @@ -308,12 +313,11 @@ gets(char *cp) } /* - * Set rootdev to match (name), given that we expect it to - * refer to a disk-like device. + * Convert a given name to the dev_t of the disk-like device + * it refers to. */ -static int -setrootbyname(char *name) -{ +dev_t +getdiskbyname(char *name) { char *cp; int cd, unit, slice, part; dev_t dev; @@ -329,11 +333,11 @@ setrootbyname(char *name) cp++; if (cp == name) { printf("missing device name\n"); - return(1); + return (NODEV); } if (*cp == '\0') { printf("missing unit number\n"); - return(1); + return (NODEV); } unit = *cp - '0'; *cp++ = '\0'; @@ -344,7 +348,7 @@ setrootbyname(char *name) goto gotit; } printf("no such device '%s'\n", name); - return (2); + return (NODEV); gotit: while (*cp >= '0' && *cp <= '9') unit += 10 * unit + *cp++ - '0'; @@ -358,9 +362,42 @@ gotit: } if (*cp != '\0') { printf("junk after name\n"); - return (1); + return (NODEV); + } + return (makedev(cd, dkmakeminor(unit, slice, part))); +} + +/* + * Set rootdev to match (name), given that we expect it to + * refer to a disk-like device. + */ +static int +setrootbyname(char *name) +{ + dev_t diskdev; + + diskdev = getdiskbyname(name); + if (diskdev != NODEV) { + rootdev = diskdev; + return (0); } - rootdev = makedev(cd, dkmakeminor(unit, slice, part)); - return 0; + + return (1); } +#ifdef DDB +DB_SHOW_COMMAND(disk, db_getdiskbyname) +{ + dev_t dev; + + if (modif[0] == '\0') { + db_error("usage: show disk/devicename"); + return; + } + dev = getdiskbyname(modif); + if (dev != NODEV) + db_printf("dev_t = %p\n", dev); + else + db_printf("No disk device matched.\n"); +} +#endif |