summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-12-31 13:03:42 +0000
committerphk <phk@FreeBSD.org>2000-12-31 13:03:42 +0000
commit0ae4f0870d3ebd2278c6fbfb3a5ac831de8552dd (patch)
tree656a2ebff1c6086df34d2ec409b289128616d8e6 /sbin
parentbea29a6c3737eff0c596ea630724fb89fa87956d (diff)
downloadFreeBSD-src-0ae4f0870d3ebd2278c6fbfb3a5ac831de8552dd.zip
FreeBSD-src-0ae4f0870d3ebd2278c6fbfb3a5ac831de8552dd.tar.gz
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.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mdconfig/mdconfig.c19
1 files changed, 13 insertions, 6 deletions
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);
}
OpenPOWER on IntegriCloud