1*6bb51422Spooka /* $NetBSD: dm_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $ */
282319721Spooka
382319721Spooka /*
482319721Spooka * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
582319721Spooka *
682319721Spooka * Redistribution and use in source and binary forms, with or without
782319721Spooka * modification, are permitted provided that the following conditions
882319721Spooka * are met:
982319721Spooka * 1. Redistributions of source code must retain the above copyright
1082319721Spooka * notice, this list of conditions and the following disclaimer.
1182319721Spooka * 2. Redistributions in binary form must reproduce the above copyright
1282319721Spooka * notice, this list of conditions and the following disclaimer in the
1382319721Spooka * documentation and/or other materials provided with the distribution.
1482319721Spooka *
1582319721Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1682319721Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1782319721Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1882319721Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1982319721Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2082319721Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2182319721Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2282319721Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2382319721Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2482319721Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2582319721Spooka * SUCH DAMAGE.
2682319721Spooka */
2782319721Spooka
2882319721Spooka #include <sys/cdefs.h>
29*6bb51422Spooka __KERNEL_RCSID(0, "$NetBSD: dm_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $");
3082319721Spooka
3182319721Spooka #include <sys/param.h>
3282319721Spooka #include <sys/conf.h>
3382319721Spooka #include <sys/device.h>
3482319721Spooka #include <sys/stat.h>
3582319721Spooka #include <sys/filedesc.h>
3682319721Spooka
3782319721Spooka #include <sys/vfs_syscalls.h>
3882319721Spooka
39*6bb51422Spooka #include <rump-sys/kern.h>
40*6bb51422Spooka #include <rump-sys/vfs.h>
4182319721Spooka
RUMP_COMPONENT(RUMP_COMPONENT_DEV)4282319721Spooka RUMP_COMPONENT(RUMP_COMPONENT_DEV)
4382319721Spooka {
4482319721Spooka extern const struct bdevsw dm_bdevsw;
4582319721Spooka extern const struct cdevsw dm_cdevsw;
4682319721Spooka devmajor_t bmaj, cmaj;
4782319721Spooka int error;
4882319721Spooka
4982319721Spooka /* go, mydevfs */
5082319721Spooka bmaj = cmaj = -1;
5182319721Spooka
5282319721Spooka if ((error = devsw_attach("dm", &dm_bdevsw, &bmaj,
5382319721Spooka &dm_cdevsw, &cmaj)) != 0)
5482319721Spooka panic("cannot attach dm: %d", error);
5582319721Spooka
5682319721Spooka do_sys_mkdir("/dev/mapper", 0770, UIO_SYSSPACE);
5782319721Spooka
5882319721Spooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/mapper/control", 0,
5982319721Spooka cmaj, 0, 1)) != 0) {
6082319721Spooka panic("cannot create device-mapper control device: %d", error);
6182319721Spooka
6282319721Spooka }
6382319721Spooka }
64