xref: /netbsd-src/sys/rump/dev/lib/libcgd/cgd_component.c (revision 9e4ecfb022a58a6da39774313d1d0d58cacee8d7)
1*9e4ecfb0Spgoyette /*	$NetBSD: cgd_component.c,v 1.3 2016/07/25 12:45:13 pgoyette Exp $	*/
27e38394aSpooka 
37e38394aSpooka /*
47e38394aSpooka  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
57e38394aSpooka  *
67e38394aSpooka  * Redistribution and use in source and binary forms, with or without
77e38394aSpooka  * modification, are permitted provided that the following conditions
87e38394aSpooka  * are met:
97e38394aSpooka  * 1. Redistributions of source code must retain the above copyright
107e38394aSpooka  *    notice, this list of conditions and the following disclaimer.
117e38394aSpooka  * 2. Redistributions in binary form must reproduce the above copyright
127e38394aSpooka  *    notice, this list of conditions and the following disclaimer in the
137e38394aSpooka  *    documentation and/or other materials provided with the distribution.
147e38394aSpooka  *
157e38394aSpooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
167e38394aSpooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
177e38394aSpooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
187e38394aSpooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
197e38394aSpooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
207e38394aSpooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
217e38394aSpooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
227e38394aSpooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
237e38394aSpooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
247e38394aSpooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
257e38394aSpooka  * SUCH DAMAGE.
267e38394aSpooka  */
277e38394aSpooka 
287e38394aSpooka #include <sys/cdefs.h>
29*9e4ecfb0Spgoyette __KERNEL_RCSID(0, "$NetBSD: cgd_component.c,v 1.3 2016/07/25 12:45:13 pgoyette Exp $");
307e38394aSpooka 
317e38394aSpooka #include <sys/param.h>
327e38394aSpooka #include <sys/conf.h>
337e38394aSpooka #include <sys/device.h>
347e38394aSpooka #include <sys/stat.h>
357e38394aSpooka 
366bb51422Spooka #include <rump-sys/kern.h>
376bb51422Spooka #include <rump-sys/vfs.h>
387e38394aSpooka 
RUMP_COMPONENT(RUMP_COMPONENT_DEV)397e38394aSpooka RUMP_COMPONENT(RUMP_COMPONENT_DEV)
407e38394aSpooka {
417e38394aSpooka 	extern const struct bdevsw cgd_bdevsw;
427e38394aSpooka 	extern const struct cdevsw cgd_cdevsw;
43*9e4ecfb0Spgoyette 	extern devmajor_t cgd_bmajor, cgd_cmajor;
447e38394aSpooka 	int error;
457e38394aSpooka 
467e38394aSpooka 	/* go, mydevfs */
477e38394aSpooka 
48*9e4ecfb0Spgoyette 	if ((error = devsw_attach("cgd", &cgd_bdevsw, &cgd_bmajor,
49*9e4ecfb0Spgoyette 	    &cgd_cdevsw, &cgd_cmajor)) != 0)
507e38394aSpooka 		panic("cannot attach cgd: %d", error);
517e38394aSpooka 
527e38394aSpooka 	if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/cgd0", 'a',
53*9e4ecfb0Spgoyette 	    cgd_bmajor, 0, 7)) != 0)
547e38394aSpooka 		panic("cannot create cooked cgd dev nodes: %d", error);
557e38394aSpooka 	if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rcgd0", 'a',
56*9e4ecfb0Spgoyette 	    cgd_cmajor, 0, 7)) != 0)
577e38394aSpooka 		panic("cannot create raw cgd dev nodes: %d", error);
58*9e4ecfb0Spgoyette 
59*9e4ecfb0Spgoyette 	devsw_detach(&cgd_bdevsw, &cgd_cdevsw);
607e38394aSpooka }
61