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