1 /* $NetBSD: mdconfig.c,v 1.4 2005/11/01 01:42:29 chs Exp $ */
4 * Copyright (c) 1995 Gordon W. Ross
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/cdefs.h>
30 __RCSID("$NetBSD: mdconfig.c,v 1.4 2005/11/01 01:42:29 chs Exp $");
34 * This program exists for the sole purpose of providing
35 * user-space memory for the new memory-disk driver (md).
36 * The job done by this is similar to mount_mfs.
37 * (But this design allows any filesystem format!)
40 #include <sys/types.h>
41 #include <sys/ioctl.h>
43 #include <sys/param.h>
51 int main
__P((int, char **));
63 fprintf(stderr
, "usage: mdconfig <device> <%d-byte-blocks>\n",
68 nblks
= (size_t)strtoul(argv
[2], NULL
, 0);
70 fprintf(stderr
, "invalid number of blocks\n");
73 md
.md_size
= nblks
<< DEV_BSHIFT
;
75 fd
= open(argv
[1], O_RDWR
, 0);
81 md
.md_addr
= mmap(NULL
, md
.md_size
,
82 PROT_READ
| PROT_WRITE
,
83 MAP_ANON
| MAP_PRIVATE
,
85 if (md
.md_addr
== MAP_FAILED
) {
91 md
.md_type
= MD_UMEM_SERVER
;
92 if (ioctl(fd
, MD_SETCONF
, &md
)) {