vnd_component.c revision 1.2
11.2Spooka/*	$NetBSD: vnd_component.c,v 1.2 2016/01/26 23:12:16 pooka Exp $	*/
21.1Sprlw1
31.1Sprlw1/*
41.1Sprlw1 * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
51.1Sprlw1 *
61.1Sprlw1 * Redistribution and use in source and binary forms, with or without
71.1Sprlw1 * modification, are permitted provided that the following conditions
81.1Sprlw1 * are met:
91.1Sprlw1 * 1. Redistributions of source code must retain the above copyright
101.1Sprlw1 *    notice, this list of conditions and the following disclaimer.
111.1Sprlw1 * 2. Redistributions in binary form must reproduce the above copyright
121.1Sprlw1 *    notice, this list of conditions and the following disclaimer in the
131.1Sprlw1 *    documentation and/or other materials provided with the distribution.
141.1Sprlw1 *
151.1Sprlw1 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
161.1Sprlw1 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
171.1Sprlw1 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
181.1Sprlw1 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
191.1Sprlw1 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
201.1Sprlw1 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
211.1Sprlw1 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Sprlw1 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
231.1Sprlw1 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
241.1Sprlw1 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
251.1Sprlw1 * SUCH DAMAGE.
261.1Sprlw1 */
271.1Sprlw1
281.1Sprlw1#include <sys/cdefs.h>
291.2Spooka__KERNEL_RCSID(0, "$NetBSD: vnd_component.c,v 1.2 2016/01/26 23:12:16 pooka Exp $");
301.1Sprlw1
311.1Sprlw1#include <sys/param.h>
321.1Sprlw1#include <sys/conf.h>
331.1Sprlw1#include <sys/device.h>
341.1Sprlw1#include <sys/stat.h>
351.1Sprlw1
361.2Spooka#include <rump-sys/kern.h>
371.2Spooka#include <rump-sys/vfs.h>
381.1Sprlw1
391.1Sprlw1RUMP_COMPONENT(RUMP_COMPONENT_DEV)
401.1Sprlw1{
411.1Sprlw1	extern const struct bdevsw vnd_bdevsw;
421.1Sprlw1	extern const struct cdevsw vnd_cdevsw;
431.1Sprlw1	devmajor_t bmaj, cmaj;
441.1Sprlw1	int error;
451.1Sprlw1
461.1Sprlw1	/* go, mydevfs */
471.1Sprlw1	bmaj = cmaj = -1;
481.1Sprlw1
491.1Sprlw1	if ((error = devsw_attach("/dev/vnd0", &vnd_bdevsw, &bmaj,
501.1Sprlw1	    &vnd_cdevsw, &cmaj)) != 0)
511.1Sprlw1		panic("cannot attach vnd: %d", error);
521.1Sprlw1
531.1Sprlw1	if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/vnd0", 'a',
541.1Sprlw1	    bmaj, 0, 7)) != 0)
551.1Sprlw1		panic("cannot create cooked vnd dev nodes: %d", error);
561.1Sprlw1	if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rvnd0", 'a',
571.1Sprlw1	    cmaj, 0, 7)) != 0)
581.1Sprlw1		panic("cannot create raw vnd dev nodes: %d", error);
591.1Sprlw1}
60