diff options
author | Brian Feldman <green@FreeBSD.org> | 2000-03-20 16:28:35 +0000 |
---|---|---|
committer | Brian Feldman <green@FreeBSD.org> | 2000-03-20 16:28:35 +0000 |
commit | 16aae9cbc06b4c93802ba5bb59985aa85a096e73 (patch) | |
tree | 78aa1032c147a04b548e665f653515e8cf387179 /sys/kern/vfs_mount.c | |
parent | 0ef1d1f59c201fee80ddd568a3eb7f2ddd44e099 (diff) | |
download | src-test2-16aae9cbc06b4c93802ba5bb59985aa85a096e73.tar.gz src-test2-16aae9cbc06b4c93802ba5bb59985aa85a096e73.zip |
Notes
Diffstat (limited to 'sys/kern/vfs_mount.c')
-rw-r--r-- | sys/kern/vfs_mount.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 8aaa4824cb4f..e2c67e20cb1b 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.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 |