diff options
author | dd <dd@FreeBSD.org> | 2001-06-21 01:36:09 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-06-21 01:36:09 +0000 |
commit | 38354648cc10dc803fb9e88ec5390727a0c69d0c (patch) | |
tree | 34d0efc7c778b3e64392d502c86f0ffb87d2237d /sbin/mdconfig/mdconfig.c | |
parent | e3e9edb5780d3f7505cce41852919bb9518ed8d7 (diff) | |
download | FreeBSD-src-38354648cc10dc803fb9e88ec5390727a0c69d0c.zip FreeBSD-src-38354648cc10dc803fb9e88ec5390727a0c69d0c.tar.gz |
Fail if -s isn't specified for an MD_MALLOC or MD_SWAP disk; the
driver itself obviously won't configure such a disk, but the error
returned (EDOM) is more cryptic to the average user than it should be.
Also assert that the argument to -u is in fact a valid unit; don't
just accept any string to mean 0.
Approved by: phk
Diffstat (limited to 'sbin/mdconfig/mdconfig.c')
-rw-r--r-- | sbin/mdconfig/mdconfig.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 28618b8d..cdf5de9 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -148,7 +148,9 @@ main(int argc, char **argv) optarg += 5; if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1)) optarg += 2; - mdio.md_unit = strtoul(optarg, NULL, 0); + mdio.md_unit = strtoul(optarg, &p, 0); + if ((unsigned)mdio.md_unit == ULONG_MAX || *p != '\0') + errx(1, "bad unit: %s", optarg); mdio.md_options &= ~MD_AUTOUNIT; break; default: @@ -160,6 +162,10 @@ main(int argc, char **argv) fd = open("/dev/" MDCTL_NAME, O_RDWR, 0); if (fd < 0) err(1, "open(/dev/%s)", MDCTL_NAME); + if (cmdline == 2 + && (mdio.md_type == MD_MALLOC || mdio.md_type == MD_SWAP)) + if (mdio.md_size == 0) + errx(1, "must specify -s for -t malloc or -t swap"); if (action == LIST) { if (mdio.md_options & MD_AUTOUNIT) list(fd); |