compat_30_mod.c revision 1.2.4.2 1 1.2.4.2 christos /* $NetBSD: compat_30_mod.c,v 1.2.4.2 2019/06/10 22:06:57 christos Exp $ */
2 1.2.4.2 christos
3 1.2.4.2 christos /*-
4 1.2.4.2 christos * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 1.2.4.2 christos * All rights reserved.
6 1.2.4.2 christos *
7 1.2.4.2 christos * This code is derived from software developed for The NetBSD Foundation
8 1.2.4.2 christos * by Paul Goyette
9 1.2.4.2 christos *
10 1.2.4.2 christos * Redistribution and use in source and binary forms, with or without
11 1.2.4.2 christos * modification, are permitted provided that the following conditions
12 1.2.4.2 christos * are met:
13 1.2.4.2 christos * 1. Redistributions of source code must retain the above copyright
14 1.2.4.2 christos * notice, this list of conditions and the following disclaimer.
15 1.2.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.4.2 christos * notice, this list of conditions and the following disclaimer in the
17 1.2.4.2 christos * documentation and/or other materials provided with the distribution.
18 1.2.4.2 christos *
19 1.2.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.2.4.2 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.2.4.2 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.2.4.2 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.2.4.2 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.2.4.2 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.2.4.2 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.2.4.2 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.2.4.2 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.2.4.2 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.2.4.2 christos * POSSIBILITY OF SUCH DAMAGE.
30 1.2.4.2 christos */
31 1.2.4.2 christos
32 1.2.4.2 christos /*
33 1.2.4.2 christos * Linkage for the compat module: spaghetti.
34 1.2.4.2 christos */
35 1.2.4.2 christos
36 1.2.4.2 christos #include <sys/cdefs.h>
37 1.2.4.2 christos __KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.2.4.2 2019/06/10 22:06:57 christos Exp $");
38 1.2.4.2 christos
39 1.2.4.2 christos #if defined(_KERNEL_OPT)
40 1.2.4.2 christos #include "opt_compat_netbsd.h"
41 1.2.4.2 christos #endif
42 1.2.4.2 christos
43 1.2.4.2 christos #include <sys/systm.h>
44 1.2.4.2 christos #include <sys/module.h>
45 1.2.4.2 christos #include <sys/sysctl.h>
46 1.2.4.2 christos #include <sys/syscall.h>
47 1.2.4.2 christos #include <sys/syscallvar.h>
48 1.2.4.2 christos #include <sys/syscallargs.h>
49 1.2.4.2 christos
50 1.2.4.2 christos #include <dev/biovar.h>
51 1.2.4.2 christos
52 1.2.4.2 christos #include <compat/common/compat_util.h>
53 1.2.4.2 christos #include <compat/common/compat_mod.h>
54 1.2.4.2 christos
55 1.2.4.2 christos int
56 1.2.4.2 christos compat_30_init(void)
57 1.2.4.2 christos {
58 1.2.4.2 christos int error = 0;
59 1.2.4.2 christos
60 1.2.4.2 christos error = vfs_syscalls_30_init();
61 1.2.4.2 christos if (error != 0)
62 1.2.4.2 christos return error;
63 1.2.4.2 christos
64 1.2.4.2 christos error = kern_time_30_init();
65 1.2.4.2 christos if (error != 0) {
66 1.2.4.2 christos vfs_syscalls_30_fini();
67 1.2.4.2 christos return error;
68 1.2.4.2 christos }
69 1.2.4.2 christos bio_30_init();
70 1.2.4.2 christos vnd_30_init();
71 1.2.4.2 christos usb_30_init();
72 1.2.4.2 christos
73 1.2.4.2 christos return error;
74 1.2.4.2 christos }
75 1.2.4.2 christos
76 1.2.4.2 christos int
77 1.2.4.2 christos compat_30_fini(void)
78 1.2.4.2 christos {
79 1.2.4.2 christos int error = 0;
80 1.2.4.2 christos
81 1.2.4.2 christos usb_30_fini();
82 1.2.4.2 christos vnd_30_fini();
83 1.2.4.2 christos bio_30_fini();
84 1.2.4.2 christos
85 1.2.4.2 christos error = kern_time_30_fini();
86 1.2.4.2 christos if (error != 0)
87 1.2.4.2 christos goto err1;
88 1.2.4.2 christos
89 1.2.4.2 christos error = vfs_syscalls_30_fini();
90 1.2.4.2 christos if (error != 0)
91 1.2.4.2 christos goto err2;
92 1.2.4.2 christos
93 1.2.4.2 christos return 0;
94 1.2.4.2 christos
95 1.2.4.2 christos err2:
96 1.2.4.2 christos kern_time_30_init();
97 1.2.4.2 christos err1:
98 1.2.4.2 christos bio_30_init();
99 1.2.4.2 christos vnd_30_init();
100 1.2.4.2 christos usb_30_init();
101 1.2.4.2 christos
102 1.2.4.2 christos return error;
103 1.2.4.2 christos }
104 1.2.4.2 christos
105 1.2.4.2 christos MODULE(MODULE_CLASS_EXEC, compat_30, "compat_util,compat_40");
106 1.2.4.2 christos
107 1.2.4.2 christos static int
108 1.2.4.2 christos compat_30_modcmd(modcmd_t cmd, void *arg)
109 1.2.4.2 christos {
110 1.2.4.2 christos
111 1.2.4.2 christos switch (cmd) {
112 1.2.4.2 christos case MODULE_CMD_INIT:
113 1.2.4.2 christos return compat_30_init();
114 1.2.4.2 christos case MODULE_CMD_FINI:
115 1.2.4.2 christos return compat_30_fini();
116 1.2.4.2 christos default:
117 1.2.4.2 christos return ENOTTY;
118 1.2.4.2 christos }
119 1.2.4.2 christos }
120