Yay - we got the ccd_ioctl_60 stuff to build! Now we can use that as a template for cleaning up all the others.diff -r1.1.2.6 -r1.1.2.7 src/sys/compat/common/ccd_60.c
(pgoyette)
--- src/sys/compat/common/ccd_60.c 2018/03/20 08:11:25 1.1.2.6
+++ src/sys/compat/common/ccd_60.c 2018/09/16 04:57:22 1.1.2.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ccd_60.c,v 1.1.2.6 2018/03/20 08:11:25 pgoyette Exp $ */ | 1 | /* $NetBSD: ccd_60.c,v 1.1.2.7 2018/09/16 04:57:22 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -16,27 +16,27 @@ | @@ -16,27 +16,27 @@ | |||
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | #include <sys/cdefs.h> | 28 | #include <sys/cdefs.h> | |
29 | __KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1.2.6 2018/03/20 08:11:25 pgoyette Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1.2.7 2018/09/16 04:57:22 pgoyette Exp $"); | |
30 | 30 | |||
31 | #ifdef _KERNEL_OPT | 31 | #ifdef _KERNEL_OPT | |
32 | #include "opt_compat_netbsd.h" | 32 | #include "opt_compat_netbsd.h" | |
33 | #endif | 33 | #endif | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/disk.h> | 37 | #include <sys/disk.h> | |
38 | #include <sys/lwp.h> | 38 | #include <sys/lwp.h> | |
39 | #include <sys/compat_stub.h> | 39 | #include <sys/compat_stub.h> | |
40 | 40 | |||
41 | #include <dev/ccdvar.h> | 41 | #include <dev/ccdvar.h> | |
42 | #include <compat/sys/ccdvar.h> | 42 | #include <compat/sys/ccdvar.h> | |
@@ -81,26 +81,29 @@ compat_60_ccdioctl(dev_t dev, u_long cmd | @@ -81,26 +81,29 @@ compat_60_ccdioctl(dev_t dev, u_long cmd | |||
81 | if (data == NULL) | 81 | if (data == NULL) | |
82 | return ENOSYS; | 82 | return ENOSYS; | |
83 | /* | 83 | /* | |
84 | * ccio_size member not used, so existing struct OK | 84 | * ccio_size member not used, so existing struct OK | |
85 | * drop through to existing non-compat version | 85 | * drop through to existing non-compat version | |
86 | */ | 86 | */ | |
87 | return (*f)(dev, CCDIOCCLR, data, flag, l); | 87 | return (*f)(dev, CCDIOCCLR, data, flag, l); | |
88 | #endif | 88 | #endif | |
89 | default: | 89 | default: | |
90 | return ENOSYS; | 90 | return ENOSYS; | |
91 | } | 91 | } | |
92 | } | 92 | } | |
93 | 93 | |||
94 | COMPAT_SET_HOOK(ccd_ioctl_60_hook, "ccd_60", compat_60_ccdioctl); | |||
95 | COMPAT_UNSET_HOOK(ccd_ioctl_60_hook); | |||
96 | ||||
94 | void | 97 | void | |
95 | ccd_60_init(void) | 98 | ccd_60_init(void) | |
96 | { | 99 | { | |
97 | 100 | |||
98 | compat_ccd_ioctl_60 = compat_60_ccdioctl; | 101 | ccd_ioctl_60_hook_set(); | |
99 | } | 102 | } | |
100 | 103 | |||
101 | void | 104 | void | |
102 | ccd_60_fini(void) | 105 | ccd_60_fini(void) | |
103 | { | 106 | { | |
104 | 107 | |||
105 | compat_ccd_ioctl_60 = (void *)enosys; | 108 | ccd_ioctl_60_hook_unset(); | |
106 | } | 109 | } |
--- src/sys/dev/ccd.c 2018/03/23 09:22:24 1.175.2.4
+++ src/sys/dev/ccd.c 2018/09/16 04:57:22 1.175.2.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ccd.c,v 1.175.2.4 2018/03/23 09:22:24 pgoyette Exp $ */ | 1 | /* $NetBSD: ccd.c,v 1.175.2.5 2018/09/16 04:57:22 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe, and by Andrew Doran. | 8 | * by Jason R. Thorpe, and by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -78,27 +78,27 @@ | @@ -78,27 +78,27 @@ | |||
78 | * sc_stop, sc_bufq and b_resid from master buffers. | 78 | * sc_stop, sc_bufq and b_resid from master buffers. | |
79 | * | 79 | * | |
80 | * => a combination of CCDF_INITED, sc_inflight, and sc_iolock is used to | 80 | * => a combination of CCDF_INITED, sc_inflight, and sc_iolock is used to | |
81 | * serialize I/O and configuration changes. | 81 | * serialize I/O and configuration changes. | |
82 | * | 82 | * | |
83 | * => the in-core disk label does not change while the device is open. | 83 | * => the in-core disk label does not change while the device is open. | |
84 | * | 84 | * | |
85 | * On memory consumption: ccd fans out I/O requests and so needs to | 85 | * On memory consumption: ccd fans out I/O requests and so needs to | |
86 | * allocate memory. If the system is desperately low on memory, we | 86 | * allocate memory. If the system is desperately low on memory, we | |
87 | * single thread I/O. | 87 | * single thread I/O. | |
88 | */ | 88 | */ | |
89 | 89 | |||
90 | #include <sys/cdefs.h> | 90 | #include <sys/cdefs.h> | |
91 | __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.4 2018/03/23 09:22:24 pgoyette Exp $"); | 91 | __KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175.2.5 2018/09/16 04:57:22 pgoyette Exp $"); | |
92 | 92 | |||
93 | #if defined(_KERNEL_OPT) | 93 | #if defined(_KERNEL_OPT) | |
94 | #include "opt_compat_netbsd.h" | 94 | #include "opt_compat_netbsd.h" | |
95 | #endif | 95 | #endif | |
96 | 96 | |||
97 | #include <sys/param.h> | 97 | #include <sys/param.h> | |
98 | #include <sys/systm.h> | 98 | #include <sys/systm.h> | |
99 | #include <sys/kernel.h> | 99 | #include <sys/kernel.h> | |
100 | #include <sys/proc.h> | 100 | #include <sys/proc.h> | |
101 | #include <sys/errno.h> | 101 | #include <sys/errno.h> | |
102 | #include <sys/buf.h> | 102 | #include <sys/buf.h> | |
103 | #include <sys/kmem.h> | 103 | #include <sys/kmem.h> | |
104 | #include <sys/pool.h> | 104 | #include <sys/pool.h> | |
@@ -1046,26 +1046,36 @@ ccdread(dev_t dev, struct uio *uio, int | @@ -1046,26 +1046,36 @@ ccdread(dev_t dev, struct uio *uio, int | |||
1046 | if (ccddebug & CCDB_FOLLOW) | 1046 | if (ccddebug & CCDB_FOLLOW) | |
1047 | printf("ccdread(0x%"PRIx64", %p)\n", dev, uio); | 1047 | printf("ccdread(0x%"PRIx64", %p)\n", dev, uio); | |
1048 | #endif | 1048 | #endif | |
1049 | if ((cs = ccdget(unit, 0)) == NULL) | 1049 | if ((cs = ccdget(unit, 0)) == NULL) | |
1050 | return 0; | 1050 | return 0; | |
1051 | 1051 | |||
1052 | /* Unlocked advisory check, ccdstrategy check is synchronous. */ | 1052 | /* Unlocked advisory check, ccdstrategy check is synchronous. */ | |
1053 | if ((cs->sc_flags & CCDF_INITED) == 0) | 1053 | if ((cs->sc_flags & CCDF_INITED) == 0) | |
1054 | return (ENXIO); | 1054 | return (ENXIO); | |
1055 | 1055 | |||
1056 | return (physio(ccdstrategy, NULL, dev, B_READ, minphys, uio)); | 1056 | return (physio(ccdstrategy, NULL, dev, B_READ, minphys, uio)); | |
1057 | } | 1057 | } | |
1058 | 1058 | |||
1059 | /* Hook the compat_60 ioctl code | |||
1060 | * | |||
1061 | * This looks ugly, since we pass the "real" ioctl function as an | |||
1062 | * argument to the compat_xxx function. | |||
1063 | */ | |||
1064 | COMPAT_CALL_HOOK(ccd_ioctl_60_hook, f, (dev_t dev, u_long cmd, void *data, | |||
1065 | int flag, struct lwp *l, int (*ff)(dev_t, u_long, void *, int, | |||
1066 | struct lwp *)), | |||
1067 | (dev, cmd, data, flag, l, ccdioctl), enosys()); | |||
1068 | ||||
1059 | /* ARGSUSED */ | 1069 | /* ARGSUSED */ | |
1060 | static int | 1070 | static int | |
1061 | ccdwrite(dev_t dev, struct uio *uio, int flags) | 1071 | ccdwrite(dev_t dev, struct uio *uio, int flags) | |
1062 | { | 1072 | { | |
1063 | int unit = ccdunit(dev); | 1073 | int unit = ccdunit(dev); | |
1064 | struct ccd_softc *cs; | 1074 | struct ccd_softc *cs; | |
1065 | 1075 | |||
1066 | #ifdef DEBUG | 1076 | #ifdef DEBUG | |
1067 | if (ccddebug & CCDB_FOLLOW) | 1077 | if (ccddebug & CCDB_FOLLOW) | |
1068 | printf("ccdwrite(0x%"PRIx64", %p)\n", dev, uio); | 1078 | printf("ccdwrite(0x%"PRIx64", %p)\n", dev, uio); | |
1069 | #endif | 1079 | #endif | |
1070 | if ((cs = ccdget(unit, 0)) == NULL) | 1080 | if ((cs = ccdget(unit, 0)) == NULL) | |
1071 | return ENOENT; | 1081 | return ENOENT; | |
@@ -1088,38 +1098,39 @@ ccdioctl(dev_t dev, u_long cmd, void *da | @@ -1088,38 +1098,39 @@ ccdioctl(dev_t dev, u_long cmd, void *da | |||
1088 | kauth_cred_t uc; | 1098 | kauth_cred_t uc; | |
1089 | char **cpp; | 1099 | char **cpp; | |
1090 | struct pathbuf *pb; | 1100 | struct pathbuf *pb; | |
1091 | struct vnode **vpp; | 1101 | struct vnode **vpp; | |
1092 | #ifdef __HAVE_OLD_DISKLABEL | 1102 | #ifdef __HAVE_OLD_DISKLABEL | |
1093 | struct disklabel newlabel; | 1103 | struct disklabel newlabel; | |
1094 | #endif | 1104 | #endif | |
1095 | 1105 | |||
1096 | switch (cmd) { | 1106 | switch (cmd) { | |
1097 | case CCDIOCSET: | 1107 | case CCDIOCSET: | |
1098 | make = 1; | 1108 | make = 1; | |
1099 | break; | 1109 | break; | |
1100 | default: | 1110 | default: | |
1101 | if ((*compat_ccd_ioctl_60)(0, cmd, NULL, 0, NULL, NULL) == 0) | 1111 | if (ccd_ioctl_60_hook_f_call(0, cmd, NULL, 0, NULL, NULL) | |
1112 | == 0) | |||
1102 | make = 1; | 1113 | make = 1; | |
1103 | else | 1114 | else | |
1104 | make = 0; | 1115 | make = 0; | |
1105 | break; | 1116 | break; | |
1106 | } | 1117 | } | |
1107 | 1118 | |||
1108 | if ((cs = ccdget(unit, make)) == NULL) | 1119 | if ((cs = ccdget(unit, make)) == NULL) | |
1109 | return ENOENT; | 1120 | return ENOENT; | |
1110 | uc = kauth_cred_get(); | 1121 | uc = kauth_cred_get(); | |
1111 | 1122 | |||
1112 | error = (*compat_ccd_ioctl_60)(dev, cmd, data, flag, l, ccdioctl); | 1123 | error = ccd_ioctl_60_hook_f_call(dev, cmd, data, flag, l, ccdioctl); | |
1113 | if (error != ENOSYS) | 1124 | if (error != ENOSYS) | |
1114 | return error; | 1125 | return error; | |
1115 | 1126 | |||
1116 | /* Must be open for writes for these commands... */ | 1127 | /* Must be open for writes for these commands... */ | |
1117 | switch (cmd) { | 1128 | switch (cmd) { | |
1118 | case CCDIOCSET: | 1129 | case CCDIOCSET: | |
1119 | case CCDIOCCLR: | 1130 | case CCDIOCCLR: | |
1120 | case DIOCSDINFO: | 1131 | case DIOCSDINFO: | |
1121 | case DIOCWDINFO: | 1132 | case DIOCWDINFO: | |
1122 | case DIOCCACHESYNC: | 1133 | case DIOCCACHESYNC: | |
1123 | case DIOCAWEDGE: | 1134 | case DIOCAWEDGE: | |
1124 | case DIOCDWEDGE: | 1135 | case DIOCDWEDGE: | |
1125 | case DIOCMWEDGES: | 1136 | case DIOCMWEDGES: |
--- src/sys/kern/compat_stub.c 2018/09/15 05:56:50 1.1.2.16
+++ src/sys/kern/compat_stub.c 2018/09/16 04:57:22 1.1.2.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: compat_stub.c,v 1.1.2.16 2018/09/15 05:56:50 pgoyette Exp $ */ | 1 | /* $NetBSD: compat_stub.c,v 1.1.2.17 2018/09/16 04:57:22 pgoyette Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Goyette | 8 | * by Paul Goyette | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -54,28 +54,28 @@ int (*vec_ntp_timestatus)(void) = ntp_ti | @@ -54,28 +54,28 @@ int (*vec_ntp_timestatus)(void) = ntp_ti | |||
54 | #else | 54 | #else | |
55 | void (*vec_ntp_gettime)(struct ntptimeval *) = NULL; | 55 | void (*vec_ntp_gettime)(struct ntptimeval *) = NULL; | |
56 | int (*vec_ntp_timestatus)(void) = NULL; | 56 | int (*vec_ntp_timestatus)(void) = NULL; | |
57 | #endif | 57 | #endif | |
58 | 58 | |||
59 | #if NUSB > 0 | 59 | #if NUSB > 0 | |
60 | #include <dev/usb/usb.h> | 60 | #include <dev/usb/usb.h> | |
61 | #include <dev/usb/usbdi.h> | 61 | #include <dev/usb/usbdi.h> | |
62 | #endif | 62 | #endif | |
63 | 63 | |||
64 | /* | 64 | /* | |
65 | * ccd device compatability ioctl | 65 | * ccd device compatability ioctl | |
66 | */ | 66 | */ | |
67 | int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *, | 67 | ||
68 | int (*f)(dev_t, u_long, void *, int, struct lwp *)) = (void *)enosys; | 68 | struct ccd_ioctl_60_hook_t ccd_ioctl_60_hook; | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * clockctl device compatability ioctl | 71 | * clockctl device compatability ioctl | |
72 | */ | 72 | */ | |
73 | int (*compat_clockctl_ioctl_50)(dev_t, u_long, void *, int, struct lwp *) = | 73 | int (*compat_clockctl_ioctl_50)(dev_t, u_long, void *, int, struct lwp *) = | |
74 | (void *)enosys; | 74 | (void *)enosys; | |
75 | 75 | |||
76 | /* | 76 | /* | |
77 | * if_sppp device compatability ioctl subroutine | 77 | * if_sppp device compatability ioctl subroutine | |
78 | */ | 78 | */ | |
79 | int (*sppp_params50)(struct sppp *, u_long, void *) = (void *)enosys; | 79 | int (*sppp_params50)(struct sppp *, u_long, void *) = (void *)enosys; | |
80 | 80 | |||
81 | /* | 81 | /* |