Module Name:    src
Committed By:   pgoyette
Date:           Tue Apr 17 07:24:55 UTC 2018

Modified Files:
        src/distrib/sets/lists/modules [pgoyette-compat]: mi
        src/sys/compat/common [pgoyette-compat]: Makefile.sysio compat_mod.c
            compat_mod.h files.common kern_sig_16.c kern_sig_43.c
            vfs_syscalls_43.c
        src/sys/kern [pgoyette-compat]: compat_stub.c
        src/sys/sys [pgoyette-compat]: compat_stub.h
Added Files:
        src/sys/compat/common [pgoyette-compat]: compat_sysctl_09_43.c

Log Message:
Finish separating the compat_09 and compat_43 stuff


To generate a diff of this commit:
cvs rdiff -u -r1.114.2.15 -r1.114.2.16 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r1.7.18.20 -r1.7.18.21 src/sys/compat/common/Makefile.sysio
cvs rdiff -u -r1.24.14.33 -r1.24.14.34 src/sys/compat/common/compat_mod.c
cvs rdiff -u -r1.1.42.20 -r1.1.42.21 src/sys/compat/common/compat_mod.h
cvs rdiff -u -r0 -r1.1.2.1 src/sys/compat/common/compat_sysctl_09_43.c
cvs rdiff -u -r1.1.2.31 -r1.1.2.32 src/sys/compat/common/files.common
cvs rdiff -u -r1.2.38.1 -r1.2.38.2 src/sys/compat/common/kern_sig_16.c
cvs rdiff -u -r1.34.56.1 -r1.34.56.2 src/sys/compat/common/kern_sig_43.c
cvs rdiff -u -r1.62.2.2 -r1.62.2.3 src/sys/compat/common/vfs_syscalls_43.c
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/sys/kern/compat_stub.c
cvs rdiff -u -r1.1.2.14 -r1.1.2.15 src/sys/sys/compat_stub.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.114.2.15 src/distrib/sets/lists/modules/mi:1.114.2.16
--- src/distrib/sets/lists/modules/mi:1.114.2.15	Tue Apr 17 00:02:58 2018
+++ src/distrib/sets/lists/modules/mi	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.114.2.15 2018/04/17 00:02:58 pgoyette Exp $
+# $NetBSD: mi,v 1.114.2.16 2018/04/17 07:24:55 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -70,6 +70,8 @@
 ./@MODULEDIR@/compat/compat.kmod		base-kernel-modules	kmod
 ./@MODULEDIR@/compat_util			base-kernel-modules	kmod
 ./@MODULEDIR@/compat_util/compat_util.kmod	base-kernel-modules	kmod
+./@MODULEDIR@/compat_sysctl_09_43		base-kernel-modules	kmod
+./@MODULEDIR@/compat_sysctl_09_43/compat_sysctl_09._43kmod	base-kernel-modules	kmod
 ./@MODULEDIR@/compat_09				base-kernel-modules	kmod
 ./@MODULEDIR@/compat_09/compat_09.kmod		base-kernel-modules	kmod
 ./@MODULEDIR@/compat_10				base-kernel-modules	kmod

Index: src/sys/compat/common/Makefile.sysio
diff -u src/sys/compat/common/Makefile.sysio:1.7.18.20 src/sys/compat/common/Makefile.sysio:1.7.18.21
--- src/sys/compat/common/Makefile.sysio:1.7.18.20	Tue Apr  3 08:29:44 2018
+++ src/sys/compat/common/Makefile.sysio	Tue Apr 17 07:24:54 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.sysio,v 1.7.18.20 2018/04/03 08:29:44 pgoyette Exp $
+#	$NetBSD: Makefile.sysio,v 1.7.18.21 2018/04/17 07:24:54 pgoyette Exp $
 
 # Sources for syscall and ioctl compatibility across the versions.
 
@@ -8,6 +8,7 @@ SRCS+=	kern_exit_43.c kern_info_43.c ker
 
 # Compatibility code for NetBSD 0.9
 SRCS+=	kern_info_09.c
+SRCS+=	compat_sysctl_09_43.c		# for compat_43 or compat_09
 
 # Compatability code for NetBSD 1.0
 SRCS+=	vfs_syscalls_10.c

Index: src/sys/compat/common/compat_mod.c
diff -u src/sys/compat/common/compat_mod.c:1.24.14.33 src/sys/compat/common/compat_mod.c:1.24.14.34
--- src/sys/compat/common/compat_mod.c:1.24.14.33	Tue Apr 17 00:02:58 2018
+++ src/sys/compat/common/compat_mod.c	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.c,v 1.24.14.33 2018/04/17 00:02:58 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.c,v 1.24.14.34 2018/04/17 07:24:55 pgoyette 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.24.14.33 2018/04/17 00:02:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.34 2018/04/17 07:24:55 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -49,15 +49,10 @@ __KERNEL_RCSID(0, "$NetBSD: compat_mod.c
 #include <sys/syscall.h>
 #include <sys/syscallargs.h>
 #include <sys/syscallvar.h>
-#include <sys/sysctl.h>
 
 #include <compat/common/compat_util.h>
 #include <compat/common/compat_mod.h>
 
-#if defined(COMPAT_09) || defined(COMPAT_43)
-static struct sysctllog *compat_clog = NULL;
-#endif
-
 static const char * const compat_includes[] = {
 	"compat_80", "compat_70", "compat_60", "compat_50", "compat_40",
 	"compat_30", "compat_20", "compat_16", "compat_14", "compat_13",
@@ -108,6 +103,9 @@ struct compat_init_fini {
 #ifdef COMPAT_10
 	{ compat_10_init, compat_10_fini },
 #endif
+#if defined(COMPAT_09) || defined(COMPAT_43)
+	{ compat_sysctl_09_43_init, compat_sysctl_09_43_fini },
+#endif
 #ifdef COMPAT_09
 	{ compat_09_init, compat_09_fini },
 #endif
@@ -140,7 +138,6 @@ compat_modcmd(modcmd_t cmd, void *arg)
 			}
 		}
 
-		compat_sysctl_init();
 		return 0;
 
 	case MODULE_CMD_FINI:
@@ -149,7 +146,6 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		 * if any component fails to fini(), re-init those
 		 * components which had already been disabled
 		 */
-		compat_sysctl_fini();
 		for (i = __arraycount(init_fini_list) - 1; i >= 0; i--) {
 			error = (*init_fini_list[i].fini)();
 			if (error != 0) {
@@ -166,24 +162,3 @@ compat_modcmd(modcmd_t cmd, void *arg)
 		return ENOTTY;
 	}
 }
-
-void
-compat_sysctl_init(void)
-{
-
-#if defined(COMPAT_09) || defined(COMPAT_43)
-	compat_sysctl_vfs(&compat_clog);
-#endif
-}
-
-void
-compat_sysctl_fini(void)
-{
- 
-#if defined(COMPAT_09) || defined(COMPAT_43)
-        sysctl_teardown(&compat_clog);
-#endif
-#if defined(COMPAT_43)
-	if_43_fini();
-#endif
-}

Index: src/sys/compat/common/compat_mod.h
diff -u src/sys/compat/common/compat_mod.h:1.1.42.20 src/sys/compat/common/compat_mod.h:1.1.42.21
--- src/sys/compat/common/compat_mod.h:1.1.42.20	Tue Apr 17 00:02:58 2018
+++ src/sys/compat/common/compat_mod.h	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_mod.h,v 1.1.42.20 2018/04/17 00:02:58 pgoyette Exp $	*/
+/*	$NetBSD: compat_mod.h,v 1.1.42.21 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,13 +32,6 @@
 #ifndef	_COMPAT_MOD_H
 #define	_COMPAT_MOD_H
 
-#include <sys/sysctl.h>
-
-void compat_sysctl_init(void);
-void compat_sysctl_fini(void);
-
-void compat_sysctl_vfs(struct sysctllog **);
-
 #ifdef COMPAT_80
 int compat_80_init(void);
 int compat_80_fini(void);
@@ -189,4 +182,9 @@ int if_43_init(void);
 int if_43_fini(void);
 #endif
 
+#if defined(COMPAT_09) || defined(COMPAT_43)
+int compat_sysctl_09_43_init(void);
+int compat_sysctl_09_43_fini(void);
+#endif
+
 #endif /* !_COMPAT_MOD_H_ */

Index: src/sys/compat/common/files.common
diff -u src/sys/compat/common/files.common:1.1.2.31 src/sys/compat/common/files.common:1.1.2.32
--- src/sys/compat/common/files.common:1.1.2.31	Tue Apr 17 00:02:58 2018
+++ src/sys/compat/common/files.common	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.common,v 1.1.2.31 2018/04/17 00:02:58 pgoyette Exp $
+#	$NetBSD: files.common,v 1.1.2.32 2018/04/17 07:24:55 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -26,6 +26,7 @@ file	compat/common/if_43.c			compat_43
 # Compatibility code for NetBSD 0.9
 file	compat/common/compat_09_mod.c		compat_09
 file	compat/common/kern_info_09.c		compat_09
+file	compat/common/compat_sysctl_09_43.c	compat_09 | compat_43
 
 # Compatability code for NetBSD 1.0
 file	compat/common/compat_10_mod.c		compat_10

Index: src/sys/compat/common/kern_sig_16.c
diff -u src/sys/compat/common/kern_sig_16.c:1.2.38.1 src/sys/compat/common/kern_sig_16.c:1.2.38.2
--- src/sys/compat/common/kern_sig_16.c:1.2.38.1	Fri Mar 30 05:35:47 2018
+++ src/sys/compat/common/kern_sig_16.c	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig_16.c,v 1.2.38.1 2018/03/30 05:35:47 pgoyette Exp $	*/
+/*	$NetBSD: kern_sig_16.c,v 1.2.38.2 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.2.38.1 2018/03/30 05:35:47 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig_16.c,v 1.2.38.2 2018/04/17 07:24:55 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -81,6 +81,10 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig_16.
 #include <sys/wait.h>
 #include <sys/kmem.h>
 
+#include <uvm/uvm_object.h>
+#include <uvm/uvm_prot.h>
+#include <uvm/uvm_pager.h>
+
 #include <compat/common/compat_mod.h>
 
 extern krwlock_t exec_lock;

Index: src/sys/compat/common/kern_sig_43.c
diff -u src/sys/compat/common/kern_sig_43.c:1.34.56.1 src/sys/compat/common/kern_sig_43.c:1.34.56.2
--- src/sys/compat/common/kern_sig_43.c:1.34.56.1	Tue Apr 17 00:02:58 2018
+++ src/sys/compat/common/kern_sig_43.c	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig_43.c,v 1.34.56.1 2018/04/17 00:02:58 pgoyette Exp $	*/
+/*	$NetBSD: kern_sig_43.c,v 1.34.56.2 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig_43.c,v 1.34.56.1 2018/04/17 00:02:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig_43.c,v 1.34.56.2 2018/04/17 07:24:55 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig_43.
 #include <sys/syscall.h>
 #include <sys/syscallvar.h>
 #include <sys/syscallargs.h>
+#include <sys/compat_stub.h>
 
 #include <sys/cpu.h>
 
@@ -259,9 +260,7 @@ compat_43_sys_killpg(struct lwp *l, cons
 	ksiginfo_t ksi;
 	int pgid = SCARG(uap, pgid);
 
-#ifdef COMPAT_09
-	pgid &= 0xffff;
-#endif
+	pgid &= kern_sig_43_pgid_mask;
 
 	if ((u_int)SCARG(uap, signum) >= NSIG)
 		return (EINVAL);

Index: src/sys/compat/common/vfs_syscalls_43.c
diff -u src/sys/compat/common/vfs_syscalls_43.c:1.62.2.2 src/sys/compat/common/vfs_syscalls_43.c:1.62.2.3
--- src/sys/compat/common/vfs_syscalls_43.c:1.62.2.2	Tue Apr 17 00:02:58 2018
+++ src/sys/compat/common/vfs_syscalls_43.c	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_43.c,v 1.62.2.2 2018/04/17 00:02:58 pgoyette Exp $	*/
+/*	$NetBSD: vfs_syscalls_43.c,v 1.62.2.3 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.62.2.2 2018/04/17 00:02:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.62.2.3 2018/04/17 07:24:55 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -58,7 +58,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls
 #include <sys/malloc.h>
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
-#include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/unistd.h>
 #include <sys/resourcevar.h>
@@ -526,66 +525,6 @@ out1:
 	return copyout(&loff, SCARG(uap, basep), sizeof(long));
 }
 
-/*
- * sysctl helper routine for vfs.generic.conf lookups.
- */
-#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
-
-static int
-sysctl_vfs_generic_conf(SYSCTLFN_ARGS)
-{
-        struct vfsconf vfc;
-	struct sysctlnode node;
-	struct vfsops *vfsp;
-	u_int vfsnum;
-
-	if (namelen != 1)
-		return (ENOTDIR);
-	vfsnum = name[0];
-	if (vfsnum >= nmountcompatnames ||
-	    mountcompatnames[vfsnum] == NULL)
-		return (EOPNOTSUPP);
-	vfsp = vfs_getopsbyname(mountcompatnames[vfsnum]);
-	if (vfsp == NULL)
-		return (EOPNOTSUPP);
-
-	vfc.vfc_vfsops = vfsp;
-	strncpy(vfc.vfc_name, vfsp->vfs_name, sizeof(vfc.vfc_name));
-	vfc.vfc_typenum = vfsnum;
-	vfc.vfc_refcount = vfsp->vfs_refcount;
-	vfc.vfc_flags = 0;
-	vfc.vfc_mountroot = vfsp->vfs_mountroot;
-	vfc.vfc_next = NULL;
-	vfs_delref(vfsp);
-
-	node = *rnode;
-	node.sysctl_data = &vfc;
-	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
-}
-
-/*
- * Top level filesystem related information gathering.
- */
-void
-compat_sysctl_vfs(struct sysctllog **clog)
-{
-
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
-		       CTLTYPE_INT, "maxtypenum",
-		       SYSCTL_DESCR("Highest valid filesystem type number"),
-		       NULL, nmountcompatnames, NULL, 0,
-		       CTL_VFS, VFS_GENERIC, VFS_MAXTYPENUM, CTL_EOL);
-	sysctl_createv(clog, 0, NULL, NULL,
-		       CTLFLAG_PERMANENT,
-		       CTLTYPE_STRUCT, "conf",
-		       SYSCTL_DESCR("Filesystem configuration information"),
-		       sysctl_vfs_generic_conf, 0, NULL,
-		       sizeof(struct vfsconf),
-		       CTL_VFS, VFS_GENERIC, VFS_CONF, CTL_EOL);
-}
-#endif
-
 int
 vfs_syscalls_43_init(void)
 {

Index: src/sys/kern/compat_stub.c
diff -u src/sys/kern/compat_stub.c:1.1.2.14 src/sys/kern/compat_stub.c:1.1.2.15
--- src/sys/kern/compat_stub.c:1.1.2.14	Tue Apr  3 08:29:44 2018
+++ src/sys/kern/compat_stub.c	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.1.2.14 2018/04/03 08:29:44 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.c,v 1.1.2.15 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -153,3 +153,8 @@ int (*rtsock14_iflist)(struct ifnet *, s
  * modctl handler for old style OSTAT
  */
 int (*compat_modstat_80)(int, struct iovec *, void *) = (void *)enosys;
+
+/*
+ * mask for kern_sig_43's killpg (updated by compat_09)
+ */
+int kern_sig_43_pgid_mask = ~0;

Index: src/sys/sys/compat_stub.h
diff -u src/sys/sys/compat_stub.h:1.1.2.14 src/sys/sys/compat_stub.h:1.1.2.15
--- src/sys/sys/compat_stub.h:1.1.2.14	Tue Apr  3 08:29:44 2018
+++ src/sys/sys/compat_stub.h	Tue Apr 17 07:24:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.h,v 1.1.2.14 2018/04/03 08:29:44 pgoyette Exp $	*/
+/* $NetBSD: compat_stub.h,v 1.1.2.15 2018/04/17 07:24:55 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -178,3 +178,8 @@ struct iovec;
 
 extern int (*compat_modstat_80)(int, struct iovec *, void *);
 #endif	/* _SYS_COMPAT_STUB_H */
+
+/*
+ * mask for kern_sig_43's killpg
+ */
+extern int kern_sig_43_pgid_mask;

Added files:

Index: src/sys/compat/common/compat_sysctl_09_43.c
diff -u /dev/null src/sys/compat/common/compat_sysctl_09_43.c:1.1.2.1
--- /dev/null	Tue Apr 17 07:24:55 2018
+++ src/sys/compat/common/compat_sysctl_09_43.c	Tue Apr 17 07:24:55 2018
@@ -0,0 +1,166 @@
+/*	$NetBSD: compat_sysctl_09_43.c,v 1.1.2.1 2018/04/17 07:24:55 pgoyette Exp $	*/
+
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ *	@(#)vfs_syscalls.c	8.28 (Berkeley) 12/10/94
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: compat_sysctl_09_43.c,v 1.1.2.1 2018/04/17 07:24:55 pgoyette Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_compat_netbsd.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/sysctl.h>
+#include <sys/module.h>
+
+#include <sys/mount.h>
+#include <sys/syscall.h>
+#include <sys/syscallvar.h>
+#include <sys/syscallargs.h>
+#include <sys/vfs_syscalls.h>
+
+#include <compat/sys/mount.h>
+#include <compat/common/compat_mod.h>
+
+/*
+ * sysctl helper routine for vfs.generic.conf lookups.
+ */
+#if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
+
+static int
+sysctl_vfs_generic_conf(SYSCTLFN_ARGS)
+{
+        struct vfsconf vfc;
+	struct sysctlnode node;
+	struct vfsops *vfsp;
+	u_int vfsnum;
+
+	if (namelen != 1)
+		return (ENOTDIR);
+	vfsnum = name[0];
+	if (vfsnum >= nmountcompatnames ||
+	    mountcompatnames[vfsnum] == NULL)
+		return (EOPNOTSUPP);
+	vfsp = vfs_getopsbyname(mountcompatnames[vfsnum]);
+	if (vfsp == NULL)
+		return (EOPNOTSUPP);
+
+	vfc.vfc_vfsops = vfsp;
+	strncpy(vfc.vfc_name, vfsp->vfs_name, sizeof(vfc.vfc_name));
+	vfc.vfc_typenum = vfsnum;
+	vfc.vfc_refcount = vfsp->vfs_refcount;
+	vfc.vfc_flags = 0;
+	vfc.vfc_mountroot = vfsp->vfs_mountroot;
+	vfc.vfc_next = NULL;
+	vfs_delref(vfsp);
+
+	node = *rnode;
+	node.sysctl_data = &vfc;
+	return (sysctl_lookup(SYSCTLFN_CALL(&node)));
+}
+
+/*
+ * Top level filesystem related information gathering.
+ */
+static int
+compat_sysctl_vfs(struct sysctllog **clog)
+{
+	int error;
+
+	error = sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+		       CTLTYPE_INT, "maxtypenum",
+		       SYSCTL_DESCR("Highest valid filesystem type number"),
+		       NULL, nmountcompatnames, NULL, 0,
+		       CTL_VFS, VFS_GENERIC, VFS_MAXTYPENUM, CTL_EOL);
+	if (error == EEXIST)
+		error = 0;
+	if (error != 0)
+		return error;
+
+	error = sysctl_createv(clog, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT,
+		       CTLTYPE_STRUCT, "conf",
+		       SYSCTL_DESCR("Filesystem configuration information"),
+		       sysctl_vfs_generic_conf, 0, NULL,
+		       sizeof(struct vfsconf),
+		       CTL_VFS, VFS_GENERIC, VFS_CONF, CTL_EOL);
+
+	return error;
+}
+#endif
+
+static struct sysctllog *clog = NULL;
+
+int
+compat_sysctl_09_43_init(void)
+{
+
+	return compat_sysctl_vfs(&clog);
+}
+
+int
+compat_sysctl_09_43_fini(void)
+{
+
+	sysctl_teardown(&clog);
+	return 0;
+}
+
+#ifdef _MODULE
+
+MODULE (MODULE_CLASS_EXEC, compat_sysctl_09_43, NULL);
+
+static int
+compat_sysctl_09_43_modcmd(modcmd_t cmd, void *arg)
+{
+
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		return compat_sysctl_09_43_init();
+	case MODULE_CMD_FINI:
+		return compat_sysctl_09_43_fini();
+	default:
+		return ENOTTY;
+	}
+}
+#endif

Reply via email to