altq_component.c revision 1.1.4.2 1 1.1.4.2 thorpej /* $NetBSD: altq_component.c,v 1.1.4.2 2021/08/01 22:42:43 thorpej Exp $ */
2 1.1.4.2 thorpej
3 1.1.4.2 thorpej /*
4 1.1.4.2 thorpej * Copyright (c) 2019 Internet Initiative Japan Inc.
5 1.1.4.2 thorpej * All rights reserved.
6 1.1.4.2 thorpej *
7 1.1.4.2 thorpej * Redistribution and use in source and binary forms, with or without
8 1.1.4.2 thorpej * modification, are permitted provided that the following conditions
9 1.1.4.2 thorpej * are met:
10 1.1.4.2 thorpej * 1. Redistributions of source code must retain the above copyright
11 1.1.4.2 thorpej * notice, this list of conditions and the following disclaimer.
12 1.1.4.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.4.2 thorpej * notice, this list of conditions and the following disclaimer in the
14 1.1.4.2 thorpej * documentation and/or other materials provided with the distribution.
15 1.1.4.2 thorpej *
16 1.1.4.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17 1.1.4.2 thorpej * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 1.1.4.2 thorpej * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 1.1.4.2 thorpej * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1.4.2 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1.4.2 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 1.1.4.2 thorpej * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1.4.2 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1.4.2 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1.4.2 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1.4.2 thorpej * SUCH DAMAGE.
27 1.1.4.2 thorpej */
28 1.1.4.2 thorpej
29 1.1.4.2 thorpej #include <sys/cdefs.h>
30 1.1.4.2 thorpej __KERNEL_RCSID(0, "$NetBSD: altq_component.c,v 1.1.4.2 2021/08/01 22:42:43 thorpej Exp $");
31 1.1.4.2 thorpej
32 1.1.4.2 thorpej #include <sys/param.h>
33 1.1.4.2 thorpej #include <sys/stat.h>
34 1.1.4.2 thorpej #include <sys/filedesc.h>
35 1.1.4.2 thorpej
36 1.1.4.2 thorpej #include <sys/vfs_syscalls.h>
37 1.1.4.2 thorpej
38 1.1.4.2 thorpej #include <net/if.h>
39 1.1.4.2 thorpej
40 1.1.4.2 thorpej #include <altq/altq.h>
41 1.1.4.2 thorpej
42 1.1.4.2 thorpej #include <rump-sys/kern.h>
43 1.1.4.2 thorpej #include <rump-sys/vfs.h>
44 1.1.4.2 thorpej
45 1.1.4.2 thorpej static void
46 1.1.4.2 thorpej create_altq_devs(void)
47 1.1.4.2 thorpej {
48 1.1.4.2 thorpej extern const struct cdevsw altq_cdevsw;
49 1.1.4.2 thorpej devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR;
50 1.1.4.2 thorpej int error;
51 1.1.4.2 thorpej
52 1.1.4.2 thorpej error = devsw_attach("altq", NULL, &bmajor,
53 1.1.4.2 thorpej &altq_cdevsw, &cmajor);
54 1.1.4.2 thorpej if (error != 0)
55 1.1.4.2 thorpej panic("altq devsw attach failed: %d", error);
56 1.1.4.2 thorpej
57 1.1.4.2 thorpej do_sys_mkdir("/dev/altq", 0755, UIO_SYSSPACE);
58 1.1.4.2 thorpej
59 1.1.4.2 thorpej error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/altq/altq", cmajor, 0);
60 1.1.4.2 thorpej if (error != 0)
61 1.1.4.2 thorpej panic("cannot create altq device node: %d", error);
62 1.1.4.2 thorpej
63 1.1.4.2 thorpej error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/altq/cbq", cmajor, ALTQT_CBQ);
64 1.1.4.2 thorpej if (error != 0)
65 1.1.4.2 thorpej panic("cannot create altq/cbq device node: %d", error);
66 1.1.4.2 thorpej }
67 1.1.4.2 thorpej
68 1.1.4.2 thorpej RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
69 1.1.4.2 thorpej {
70 1.1.4.2 thorpej
71 1.1.4.2 thorpej create_altq_devs();
72 1.1.4.2 thorpej }
73