aboutsummaryrefslogtreecommitdiff
path: root/sbin/mdconfig
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-06-21 01:36:09 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-06-21 01:36:09 +0000
commit2885b42173ff360c66e7db1c094566c1ad73060f (patch)
tree34d0efc7c778b3e64392d502c86f0ffb87d2237d /sbin/mdconfig
parent3445e8ca8105235aa94d047785ffaa072576fc29 (diff)
downloadsrc-2885b42173ff360c66e7db1c094566c1ad73060f.tar.gz
src-2885b42173ff360c66e7db1c094566c1ad73060f.zip
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
Notes
Notes: svn path=/head/; revision=78524
Diffstat (limited to 'sbin/mdconfig')
-rw-r--r--sbin/mdconfig/mdconfig.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index 28618b8dce48..cdf5de93672e 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);