diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index ed781763f3d2..280219fcb5d6 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -213,6 +213,13 @@ main(int argc, char **argv) case 'u': if (cmdline != 2 && cmdline != 3) usage(); + if (!strncmp(optarg, "/dev/", 5)) + optarg += 5; + if (!strncmp(optarg, MD_NAME, sizeof(MD_NAME) - 1)) + optarg += sizeof(MD_NAME) - 1; + mdio.md_unit = strtoul(optarg, &p, 0); + if (mdio.md_unit == (unsigned)ULONG_MAX || *p != '\0') + errx(1, "bad unit: %s", optarg); mdunit = optarg; mdio.md_options &= ~MD_AUTOUNIT; break;