Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys factor out the ccd COMPAT_60 code.
details: https://anonhg.NetBSD.org/src/rev/115b992b9ba4
branches: trunk
changeset: 360607:115b992b9ba4
user: christos <christos%NetBSD.org@localhost>
date: Sun Mar 18 20:33:52 2018 +0000
description:
factor out the ccd COMPAT_60 code.
diffstat:
sys/compat/common/Makefile.sysio | 4 +-
sys/compat/common/ccd_60.c | 103 +++++++++++++++++++++++++++++++++++++++
sys/compat/common/compat_mod.c | 7 +-
sys/compat/sys/ccdvar.h | 57 +++++++++++++++++++++
sys/dev/ccd.c | 59 ++++------------------
sys/dev/ccdvar.h | 19 +------
6 files changed, 179 insertions(+), 70 deletions(-)
diffs (truncated from 360 to 300 lines):
diff -r 78d9cd3fd8f4 -r 115b992b9ba4 sys/compat/common/Makefile.sysio
--- a/sys/compat/common/Makefile.sysio Sun Mar 18 15:42:37 2018 +0000
+++ b/sys/compat/common/Makefile.sysio Sun Mar 18 20:33:52 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.sysio,v 1.9 2018/03/17 19:00:23 christos Exp $
+# $NetBSD: Makefile.sysio,v 1.10 2018/03/18 20:33:52 christos Exp $
# Sources for syscall and ioctl compatibility across the versions.
@@ -35,7 +35,7 @@
vfs_syscalls_50.c uipc_syscalls_50.c uvm_50.c
# Compatibility code for NetBSD 6.0
-SRCS+= kern_sa_60.c tty_60.c kern_time_60.c kern_cpu_60.c
+SRCS+= kern_sa_60.c tty_60.c kern_time_60.c kern_cpu_60.c ccd_60.c
# Compatibility code for NetBSD 7.0
SRCS+= rtsock_70.c uipc_usrreq_70.c
diff -r 78d9cd3fd8f4 -r 115b992b9ba4 sys/compat/common/ccd_60.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/ccd_60.c Sun Mar 18 20:33:52 2018 +0000
@@ -0,0 +1,103 @@
+/* $NetBSD: ccd_60.c,v 1.1 2018/03/18 20:33:52 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ccd_60.c,v 1.1 2018/03/18 20:33:52 christos Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/disk.h>
+#include <sys/lwp.h>
+
+#include <dev/ccdvar.h>
+#include <compat/sys/ccdvar.h>
+
+/*
+ * Compat code must not be called if on a platform where
+ * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will
+ * be the same as CCDIOCSET_60
+ */
+static int
+compat_60_ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l,
+ int (*f)(dev_t, u_long, void *, int, struct lwp *))
+{
+ switch (cmd) {
+#if defined(COMPAT_60) && !defined(_LP64)
+ case CCDIOCSET_60: {
+ if (data == NULL)
+ return 0;
+
+ struct ccd_ioctl ccio;
+ struct ccd_ioctl_60 *ccio60 = data;
+
+ ccio.ccio_disks = ccio60->ccio_disks;
+ ccio.ccio_ndisks = ccio60->ccio_ndisks;
+ ccio.ccio_ileave = ccio60->ccio_ileave;
+ ccio.ccio_flags = ccio60->ccio_flags;
+ ccio.ccio_unit = ccio60->ccio_unit;
+ error = (*f)(dev, CCDIOCSET, &ccio, flag, l);
+ if (!error) {
+ /* Copy data back, adjust types if necessary */
+ ccio60->ccio_disks = ccio.ccio_disks;
+ ccio60->ccio_ndisks = ccio.ccio_ndisks;
+ ccio60->ccio_ileave = ccio.ccio_ileave;
+ ccio60->ccio_flags = ccio.ccio_flags;
+ ccio60->ccio_unit = ccio.ccio_unit;
+ ccio60->ccio_size = (size_t)ccio.ccio_size;
+ }
+ return error;
+ }
+
+ case CCDIOCCLR_60:
+ if (data == NULL)
+ return ENOSYS;
+ /*
+ * ccio_size member not used, so existing struct OK
+ * drop through to existing non-compat version
+ */
+ return (*f)(dev, CCDIOCLR, data, flag, l);
+#endif /* COMPAT_60 && !_LP64*/
+ default:
+ return ENOSYS;
+ }
+}
+
+void
+ccd_60_init(void)
+{
+ compat_ccd_ioctl_60 = compat_60_ccdioctl;
+}
+
+void
+ccd_60_fini(void)
+{
+ compat_ccd_ioctl_60 = (void *)enosys;
+}
diff -r 78d9cd3fd8f4 -r 115b992b9ba4 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c Sun Mar 18 15:42:37 2018 +0000
+++ b/sys/compat/common/compat_mod.c Sun Mar 18 20:33:52 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_mod.c,v 1.26 2018/03/17 19:00:23 christos Exp $ */
+/* $NetBSD: compat_mod.c,v 1.27 2018/03/18 20:33:52 christos Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.26 2018/03/17 19:00:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.27 2018/03/18 20:33:52 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -62,6 +62,7 @@
#include <compat/common/if_43.h>
#include <compat/sys/uvm.h>
#include <compat/sys/cpuio.h>
+#include <compat/sys/ccdvar.h>
#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_50)
static struct sysctllog *compat_clog = NULL;
@@ -261,6 +262,7 @@
#endif
#ifdef COMPAT_60
kern_cpu_60_init();
+ ccd_60_init();
#endif
return 0;
@@ -327,6 +329,7 @@
#endif
#ifdef COMPAT_60
kern_cpu_60_fini();
+ ccd_60_fini();
#endif
return 0;
diff -r 78d9cd3fd8f4 -r 115b992b9ba4 sys/compat/sys/ccdvar.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/sys/ccdvar.h Sun Mar 18 20:33:52 2018 +0000
@@ -0,0 +1,57 @@
+/* $NetBSD: ccdvar.h,v 1.1 2018/03/18 20:33:52 christos Exp $ */
+
+/*-
+ * Copyright (c) 2018 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _SYS_COMPAT_CCDVAR_H_
+#define _SYS_COMPAT_CCDVAR_H_
+
+#if defined(COMPAT_60) && !defined(_LP64)
+/*
+ * Old version with incorrect ccio_size
+ */
+struct ccd_ioctl_60 {
+ char **ccio_disks; /* pointer to component paths */
+ u_int ccio_ndisks; /* number of disks to concatenate */
+ int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
+ int ccio_flags; /* see sc_flags below */
+ int ccio_unit; /* unit number: use varies */
+ size_t ccio_size; /* (returned) size of ccd */
+};
+
+#define CCDIOCSET_60 _IOWR('F', 16, struct ccd_ioctl_60) /* enable ccd */
+#define CCDIOCCLR_60 _IOW('F', 17, struct ccd_ioctl_60) /* disable ccd */
+
+#endif /* COMPAT_60 && !LP64*/
+
+struct lwp;
+
+extern int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *,
+ int (*)(dev_t, u_long, void *, int, struct lwp *));
+
+void ccd_60_init(void);
+void ccd_60_fini(void);
+
+#endif /* _SYS_COMPAT_CCDVAR_H_ */
diff -r 78d9cd3fd8f4 -r 115b992b9ba4 sys/dev/ccd.c
--- a/sys/dev/ccd.c Sun Mar 18 15:42:37 2018 +0000
+++ b/sys/dev/ccd.c Sun Mar 18 20:33:52 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.175 2018/01/23 22:42:29 pgoyette Exp $ */
+/* $NetBSD: ccd.c,v 1.176 2018/03/18 20:33:52 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,11 +88,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.175 2018/01/23 22:42:29 pgoyette Exp $");
-
-#if defined(_KERNEL_OPT)
-#include "opt_compat_netbsd.h"
-#endif
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.176 2018/03/18 20:33:52 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1076,6 +1072,9 @@
return (physio(ccdstrategy, NULL, dev, B_WRITE, minphys, uio));
}
+int (*compat_ccd_ioctl_60)(dev_t, u_long, void *, int, struct lwp *,
+ int (*)(dev_t, u_long, void *, int, struct lwp *)) = (void *)enosys;
+
static int
ccdioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
@@ -1093,14 +1092,14 @@
#endif
switch (cmd) {
-#if defined(COMPAT_60) && !defined(_LP64)
- case CCDIOCSET_60:
-#endif
case CCDIOCSET:
make = 1;
break;
default:
- make = 0;
+ if ((*compat_ccd_ioctl_60)(0, cmd, NULL, 0, NULL, NULL) == 0)
+ make = 1;
+ else
+ make = 0;
break;
}
@@ -1108,45 +1107,9 @@
return ENOENT;
uc = kauth_cred_get();
-/*
- * Compat code must not be called if on a platform where
- * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will
- * be the same as CCDIOCSET_60
- */
-#if defined(COMPAT_60) && !defined(_LP64)
- switch (cmd) {
- case CCDIOCSET_60: {
- struct ccd_ioctl ccionew;
- struct ccd_ioctl_60 *ccio60 =
- (struct ccd_ioctl_60 *)data;
- ccionew.ccio_disks = ccio->ccio_disks;
- ccionew.ccio_ndisks = ccio->ccio_ndisks;
- ccionew.ccio_ileave = ccio->ccio_ileave;
- ccionew.ccio_flags = ccio->ccio_flags;
- ccionew.ccio_unit = ccio->ccio_unit;
- error = ccdioctl(dev, CCDIOCSET, &ccionew, flag, l);
Home |
Main Index |
Thread Index |
Old Index