From 0ae4f0870d3ebd2278c6fbfb3a5ac831de8552dd Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 31 Dec 2000 13:03:42 +0000 Subject: This is the first snapshot of the new all-singing-and-dancing md(4). Using the mdconfig(8) program you can now configure memory disks on malloc(9), swap or a file/vnode. preloaded md disks also work as usual. --- sbin/mdconfig/mdconfig.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'sbin') diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 31d2aba..dca1b40 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -27,8 +27,9 @@ enum {UNSET, ATTACH, DETACH} action = UNSET; void usage() { - fprintf(stderr, "Usage:\n\t"); - fprintf(stderr, "mdconfig {-a|-d} -t type [-o [no]option]... [ -f file] [-s size] [-u unit]\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\tmdconfig -a -t type [-o [no]option]... [ -f file] [-s size] [-u unit]\n"); + fprintf(stderr, "\tmdconfig -d -u unit\n"); fprintf(stderr, "\t\ttype = {malloc, preload, vnode, swap}\n"); fprintf(stderr, "\t\toption = {cluster, compress, reserve, autounit}\n"); fprintf(stderr, "\t\tsize = %%d (512 byte blocks), %%dk (kB), %%dm (MB) or %%dg (GB)\n"); @@ -57,7 +58,8 @@ main(int argc, char **argv) if (cmdline != 0) usage(); action = DETACH; - cmdline = 1; + mdio.md_options = MD_AUTOUNIT; + cmdline = 3; break; case 't': if (cmdline != 1) @@ -122,7 +124,7 @@ main(int argc, char **argv) errx(1, "Unknown suffix on -s argument"); break; case 'u': - if (cmdline != 2) + if (cmdline != 2 && cmdline != 3) usage(); mdio.md_unit = strtoul(optarg, NULL, 0); mdio.md_options &= ~MD_AUTOUNIT; @@ -135,12 +137,17 @@ main(int argc, char **argv) fd = open("/dev/mdctl", O_RDWR, 0); if (fd < 0) err(1, "open(/dev/mdctl)"); - if (action == ATTACH) + if (action == ATTACH) { i = ioctl(fd, MDIOCATTACH, &mdio); - else + } else { + if (mdio.md_options & MD_AUTOUNIT) + usage(); i = ioctl(fd, MDIOCDETACH, &mdio); + } if (i < 0) err(1, "ioctl(/dev/mdctl)"); + if (mdio.md_options & MD_AUTOUNIT) + printf("md%d\n", mdio.md_unit); return (0); } -- cgit v1.1