xref: /netbsd-src/sys/rump/dev/lib/libfss/fss_component.c (revision 2dc75bdc9e8fad4a023e63d4d49f2787d1c304bc)
1*2dc75bdcSpgoyette /*	$NetBSD: fss_component.c,v 1.4 2016/07/30 23:07:23 pgoyette Exp $	*/
204df77c1Spooka 
304df77c1Spooka /*
404df77c1Spooka  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
504df77c1Spooka  *
604df77c1Spooka  * Redistribution and use in source and binary forms, with or without
704df77c1Spooka  * modification, are permitted provided that the following conditions
804df77c1Spooka  * are met:
904df77c1Spooka  * 1. Redistributions of source code must retain the above copyright
1004df77c1Spooka  *    notice, this list of conditions and the following disclaimer.
1104df77c1Spooka  * 2. Redistributions in binary form must reproduce the above copyright
1204df77c1Spooka  *    notice, this list of conditions and the following disclaimer in the
1304df77c1Spooka  *    documentation and/or other materials provided with the distribution.
1404df77c1Spooka  *
1504df77c1Spooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1604df77c1Spooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1704df77c1Spooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1804df77c1Spooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1904df77c1Spooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2004df77c1Spooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2104df77c1Spooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2204df77c1Spooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2304df77c1Spooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2404df77c1Spooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2504df77c1Spooka  * SUCH DAMAGE.
2604df77c1Spooka  */
2704df77c1Spooka 
2804df77c1Spooka #include <sys/cdefs.h>
29*2dc75bdcSpgoyette __KERNEL_RCSID(0, "$NetBSD: fss_component.c,v 1.4 2016/07/30 23:07:23 pgoyette Exp $");
3004df77c1Spooka 
3104df77c1Spooka #include <sys/param.h>
3204df77c1Spooka #include <sys/conf.h>
3304df77c1Spooka #include <sys/device.h>
3404df77c1Spooka #include <sys/stat.h>
3504df77c1Spooka 
366bb51422Spooka #include <rump-sys/kern.h>
376bb51422Spooka #include <rump-sys/vfs.h>
3804df77c1Spooka 
RUMP_COMPONENT(RUMP_COMPONENT_DEV)3904df77c1Spooka RUMP_COMPONENT(RUMP_COMPONENT_DEV)
4004df77c1Spooka {
4104df77c1Spooka 	extern const struct bdevsw fss_bdevsw;
4204df77c1Spooka 	extern const struct cdevsw fss_cdevsw;
43*2dc75bdcSpgoyette 	extern devmajor_t fss_bmajor, fss_cmajor;
4404df77c1Spooka 	int error;
4504df77c1Spooka 
46763a6486Spgoyette 	fss_bmajor = bdevsw_lookup_major(&fss_bdevsw);
47763a6486Spgoyette 	fss_cmajor = cdevsw_lookup_major(&fss_cdevsw);
4804df77c1Spooka 
49763a6486Spgoyette 	if ((error = devsw_attach("fss", &fss_bdevsw, &fss_bmajor,
50763a6486Spgoyette 	    &fss_cdevsw, &fss_cmajor)) != 0)
5104df77c1Spooka 		panic("cannot attach fss: %d", error);
5204df77c1Spooka 
5304df77c1Spooka 	if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/fss", '0',
54763a6486Spgoyette 	    fss_bmajor, 0, 4)) != 0)
5504df77c1Spooka 		panic("cannot create cooked fss dev nodes: %d", error);
5604df77c1Spooka 	if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rfss", '0',
57763a6486Spgoyette 	    fss_cmajor, 0, 4)) != 0)
5804df77c1Spooka 		panic("cannot create raw fss dev nodes: %d", error);
59763a6486Spgoyette 
60763a6486Spgoyette 	devsw_detach(&fss_bdevsw, &fss_cdevsw);
6104df77c1Spooka }
62