svn commit: r266661 - in user/dchagin/lemul/sys: amd64/linux amd64/linux32 compat/linprocfs compat/linsysfs compat/linux conf i386/linux modules modules/linprocfs modules/linsysfs modules/linux mod...
Dmitry Chagin
dchagin at FreeBSD.org
Sun May 25 18:03:28 UTC 2014
Author: dchagin
Date: Sun May 25 18:03:26 2014
New Revision: 266661
URL: http://svnweb.freebsd.org/changeset/base/266661
Log:
Introduce a new module linux_common.ko which is intended for the
following primary purposes:
1. Remove the dependency of linsysfs and linprocfs modules from linux.ko,
which is architecture specific on amd64.
2. Incorporate into linux_common.ko general code for platforms on which
we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit).
3. Move malloc(9) declaration to linux_common.ko, to enable getting memory
usage statistics properly.
Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c
and linprocfs, linsysfs, linux and linux64 kernel modules depend on linux_common.ko.
Temporarily remove dtrace garbage from linux_mib.c and linux_util.c
In collaboration with Vassilis Laganakos.
Added:
user/dchagin/lemul/sys/compat/linux/linux_common.c (contents, props changed)
user/dchagin/lemul/sys/modules/linux_common/
user/dchagin/lemul/sys/modules/linux_common/Makefile (contents, props changed)
Modified:
user/dchagin/lemul/sys/amd64/linux/linux.h
user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c
user/dchagin/lemul/sys/amd64/linux32/linux.h
user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c
user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c
user/dchagin/lemul/sys/compat/linsysfs/linsysfs.c
user/dchagin/lemul/sys/compat/linux/linux_mib.c
user/dchagin/lemul/sys/compat/linux/linux_mib.h
user/dchagin/lemul/sys/compat/linux/linux_misc.c
user/dchagin/lemul/sys/compat/linux/linux_misc.h
user/dchagin/lemul/sys/compat/linux/linux_util.c
user/dchagin/lemul/sys/compat/linux/linux_util.h
user/dchagin/lemul/sys/conf/files.amd64
user/dchagin/lemul/sys/i386/linux/linux.h
user/dchagin/lemul/sys/i386/linux/linux_sysvec.c
user/dchagin/lemul/sys/modules/Makefile
user/dchagin/lemul/sys/modules/linprocfs/Makefile
user/dchagin/lemul/sys/modules/linsysfs/Makefile
user/dchagin/lemul/sys/modules/linux/Makefile
user/dchagin/lemul/sys/modules/linux64/Makefile
Modified: user/dchagin/lemul/sys/amd64/linux/linux.h
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux/linux.h Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/amd64/linux/linux.h Sun May 25 18:03:26 2014 (r266661)
@@ -41,10 +41,6 @@ extern u_char linux_debug_map[];
#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
#define LINUX_DTRACE linuxulator
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_LINUX);
-#endif
-
#define PTRIN(v) (void *)(v)
#define PTROUT(v) (uintptr_t)(v)
Modified: user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/amd64/linux/linux_sysvec.c Sun May 25 18:03:26 2014 (r266661)
@@ -86,14 +86,19 @@ __FBSDID("$FreeBSD$");
MODULE_VERSION(linux64, 1);
-MALLOC_DEFINE(M_LINUX, "linux64", "Linux mode structures");
-
#if BYTE_ORDER == LITTLE_ENDIAN
#define SHELLMAGIC 0x2123 /* #! */
#else
#define SHELLMAGIC 0x2321
#endif
+#if defined(DEBUG)
+SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
+ CTLTYPE_STRING | CTLFLAG_RW,
+ 0, 0, linux_sysctl_debug, "A",
+ "Linux debugging control");
+#endif
+
/*
* Allow the this functions to use the ldebug() facility
* even though they are not syscalls themselves. Map them
@@ -966,7 +971,6 @@ linux64_elf_modevent(module_t mod, int t
linux_proc_exec, (void *) (long)elf_linux_sysvec.sv_flags, 1000);
linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
- linux_osd_jail_register();
stclohz = (stathz ? stathz : hz);
if (bootverbose)
printf("Linux x86-64 ELF exec handler installed\n");
@@ -993,7 +997,6 @@ linux64_elf_modevent(module_t mod, int t
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
- linux_osd_jail_deregister();
if (bootverbose)
printf("Linux ELF exec handler removed\n");
} else
@@ -1011,4 +1014,5 @@ static moduledata_t linux64_elf_mod = {
0
};
-DECLARE_MODULE(linux64elf, linux64_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
+DECLARE_MODULE_TIED(linux64elf, linux64_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
+MODULE_DEPEND(linux64elf, linux_common, 1, 1, 1);
Modified: user/dchagin/lemul/sys/amd64/linux32/linux.h
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux32/linux.h Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/amd64/linux32/linux.h Sun May 25 18:03:26 2014 (r266661)
@@ -42,10 +42,6 @@ extern u_char linux_debug_map[];
#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
#define LINUX_DTRACE linuxulator32
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_LINUX);
-#endif
-
#define LINUX32_MAXUSER ((1ul << 32) - PAGE_SIZE)
#define LINUX32_SHAREDPAGE (LINUX32_MAXUSER - PAGE_SIZE)
#define LINUX32_USRSTACK LINUX32_SHAREDPAGE
Modified: user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/amd64/linux32/linux32_sysvec.c Sun May 25 18:03:26 2014 (r266661)
@@ -87,8 +87,6 @@ __FBSDID("$FreeBSD$");
MODULE_VERSION(linux, 1);
-MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
-
#define AUXARGS_ENTRY_32(pos, id, val) \
do { \
suword32(pos++, id); \
@@ -976,6 +974,13 @@ static u_long linux32_maxvmem = LINUX32_
SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW,
&linux32_maxvmem, 0, "");
+#if defined(DEBUG)
+SYSCTL_PROC(_compat_linux32, OID_AUTO, debug,
+ CTLTYPE_STRING | CTLFLAG_RW,
+ 0, 0, linux_sysctl_debug, "A",
+ "Linux debugging control");
+#endif
+
static void
linux32_fixlimit(struct rlimit *rl, int which)
{
@@ -1176,7 +1181,6 @@ linux_elf_modevent(module_t mod, int typ
linux_proc_exec, (void *) (long)elf_linux_sysvec.sv_flags, 1000);
linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
- linux_osd_jail_register();
stclohz = (stathz ? stathz : hz);
if (bootverbose)
printf("Linux ELF exec handler installed\n");
@@ -1203,7 +1207,6 @@ linux_elf_modevent(module_t mod, int typ
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
- linux_osd_jail_deregister();
if (bootverbose)
printf("Linux ELF exec handler removed\n");
} else
@@ -1222,3 +1225,4 @@ static moduledata_t linux_elf_mod = {
};
DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
+MODULE_DEPEND(linuxelf, linux_common, 1, 1, 1);
Modified: user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/compat/linprocfs/linprocfs.c Sun May 25 18:03:26 2014 (r266661)
@@ -39,8 +39,6 @@
* @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
*/
-#include "opt_compat.h"
-
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -597,30 +595,10 @@ linprocfs_doversion(PFS_FILL_ARGS)
{
char osname[LINUX_MAX_UTSNAME];
char osrelease[LINUX_MAX_UTSNAME];
- size_t size;
- int error = 0;
-
- size = sizeof(osname);
- if (SV_CURPROC_FLAG(SV_LP64))
- error = kernel_sysctlbyname(td, "compat.linux64.osname", &osname, &size, 0, 0, 0, 0);
- if (SV_CURPROC_FLAG(SV_ILP32) || error)
- error = kernel_sysctlbyname(td, "compat.linux.osname", &osname, &size, 0, 0, 0, 0);
- if (error)
- sbuf_printf(sb, "unknown ");
- else
- sbuf_printf(sb, "%s ", osname);
-
- error = 0;
- size = sizeof(osrelease);
- if (SV_CURPROC_FLAG(SV_LP64))
- error = kernel_sysctlbyname(td, "compat.linux64.osrelease", &osrelease, &size, 0, 0, 0, 0);
- if (SV_CURPROC_FLAG(SV_ILP32) || error)
- error = kernel_sysctlbyname(td, "compat.linux.osrelease", &osrelease, &size, 0, 0, 0, 0);
- if (error)
- sbuf_printf(sb, "version unknown (");
- else
- sbuf_printf(sb, "version %s (", osrelease);
+ linux_get_osname(td, osname);
+ linux_get_osrelease(td, osrelease);
+ sbuf_printf(sb, "%s version %s (", osname, osrelease);
linprocfs_osbuilder(td, sb);
sbuf_cat(sb, ") (gcc version " __VERSION__ ") ");
linprocfs_osbuild(td, sb);
@@ -1224,18 +1202,10 @@ static int
linprocfs_doosrelease(PFS_FILL_ARGS)
{
char osrelease[LINUX_MAX_UTSNAME];
- size_t size;
- int error = 0;
- size = sizeof(osrelease);
- if (SV_CURPROC_FLAG(SV_LP64))
- error = kernel_sysctlbyname(td, "compat.linux64.osrelease", &osrelease, &size, 0, 0, 0, 0);
- if (SV_CURPROC_FLAG(SV_ILP32) || error)
- error = kernel_sysctlbyname(td, "compat.linux.osrelease", &osrelease, &size, 0, 0, 0, 0);
- if (error)
- sbuf_printf(sb, "unknown\n");
- else
- sbuf_printf(sb, "%s\n", osrelease);
+ linux_get_osrelease(td, osrelease);
+ sbuf_printf(sb, "%s\n", osrelease);
+
return (0);
}
@@ -1246,18 +1216,10 @@ static int
linprocfs_doostype(PFS_FILL_ARGS)
{
char osname[LINUX_MAX_UTSNAME];
- size_t size;
- int error = 0;
- size = sizeof(osname);
- if (SV_CURPROC_FLAG(SV_LP64))
- error = kernel_sysctlbyname(td, "compat.linux64.osname", &osname, &size, 0, 0, 0, 0);
- if (SV_CURPROC_FLAG(SV_ILP32) || error)
- error = kernel_sysctlbyname(td, "compat.linux.osname", &osname, &size, 0, 0, 0, 0);
- if (error)
- sbuf_printf(sb, "unknown\n");
- else
- sbuf_printf(sb, "%s\n", osname);
+ linux_get_osname(td, osname);
+ sbuf_printf(sb, "%s\n", osname);
+
return (0);
}
@@ -1541,7 +1503,11 @@ linprocfs_uninit(PFS_INIT_ARGS)
}
PSEUDOFS(linprocfs, 1, 0);
+#if defined(__amd64__)
+MODULE_DEPEND(linprocfs, linux_common, 1, 1, 1);
+#else
MODULE_DEPEND(linprocfs, linux, 1, 1, 1);
+#endif
MODULE_DEPEND(linprocfs, procfs, 1, 1, 1);
MODULE_DEPEND(linprocfs, sysvmsg, 1, 1, 1);
MODULE_DEPEND(linprocfs, sysvsem, 1, 1, 1);
Modified: user/dchagin/lemul/sys/compat/linsysfs/linsysfs.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linsysfs/linsysfs.c Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/compat/linsysfs/linsysfs.c Sun May 25 18:03:26 2014 (r266661)
@@ -62,12 +62,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
-#include "opt_compat.h"
-#ifdef COMPAT_LINUX32 /* XXX */
-#include <machine/../linux32/linux.h>
-#else
-#include <machine/../linux/linux.h>
-#endif
#include <compat/linux/linux_ioctl.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_util.h>
@@ -282,4 +276,8 @@ linsysfs_uninit(PFS_INIT_ARGS)
}
PSEUDOFS(linsysfs, 1, 0);
+#if defined(__amd64__)
+MODULE_DEPEND(linsysfs, linux_common, 1, 1, 1);
+#else
MODULE_DEPEND(linsysfs, linux, 1, 1, 1);
+#endif
Added: user/dchagin/lemul/sys/compat/linux/linux_common.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/dchagin/lemul/sys/compat/linux/linux_common.c Sun May 25 18:03:26 2014 (r266661)
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2014 Vassilis Laganakos
+ * 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 AUTHOR 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 AUTHOR 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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/module.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/types.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+
+#include <compat/linux/linux_mib.h>
+
+MODULE_VERSION(linux_common, 1);
+
+
+static int
+linux_common_modevent(module_t mod, int type, void *data)
+{
+
+ switch(type) {
+ case MOD_LOAD:
+ linux_osd_jail_register();
+ break;
+ case MOD_UNLOAD:
+ linux_osd_jail_deregister();
+ break;
+ default:
+ return (EOPNOTSUPP);
+ }
+ return (0);
+}
+
+static moduledata_t linux_common_mod = {
+ "linuxcommon",
+ linux_common_modevent,
+ 0
+};
+
+DECLARE_MODULE(linuxcommon, linux_common_mod, SI_SUB_EXEC, SI_ORDER_ANY);
Modified: user/dchagin/lemul/sys/compat/linux/linux_mib.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linux/linux_mib.c Sun May 25 17:52:34 2014 (r266660)
+++ user/dchagin/lemul/sys/compat/linux/linux_mib.c Sun May 25 18:03:26 2014 (r266661)
@@ -29,8 +29,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_compat.h"
-
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/sdt.h>
@@ -41,85 +39,11 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/jail.h>
#include <sys/lock.h>
-#include <sys/mutex.h>
#include <sys/sx.h>
-#ifdef COMPAT_LINUX32
-#include <machine/../linux32/linux.h>
-#else
-#include <machine/../linux/linux.h>
-#endif
-#include <compat/linux/linux_dtrace.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_misc.h>
-/* DTrace init */
-LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
-
-/**
- * DTrace probes in this module.
- */
-LIN_SDT_PROBE_DEFINE0(mib, linux_sysctl_osname, entry);
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_osname, sysctl_string_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_osname, return, "int");
-
-LIN_SDT_PROBE_DEFINE0(mib, linux_sysctl_osrelease, entry);
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_osrelease, sysctl_string_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_osrelease, return, "int");
-LIN_SDT_PROBE_DEFINE0(mib, linux_sysctl_oss_version, entry);
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_oss_version, sysctl_string_error,
- "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_sysctl_oss_version, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_map_osrel, entry, "char *", "int *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_map_osrel, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_get_prison, entry, "struct prison *",
- "struct prison **");
-LIN_SDT_PROBE_DEFINE1(mib, linux_get_prison, return, "struct linux_prison *");
-LIN_SDT_PROBE_DEFINE2(mib, linux_alloc_prison, entry, "struct prison *",
- "struct linux_prison **");
-LIN_SDT_PROBE_DEFINE1(mib, linux_alloc_prison, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_prison_create, entry, "void *", "void *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_create, vfs_copyopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_create, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_prison_check, entry, "void *", "void *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_check, vfs_copyopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_check, vfs_getopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_check, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_prison_set, entry, "void *", "void *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_set, vfs_copyopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_set, vfs_getopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_set, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_prison_get, entry, "void *", "void *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_get, vfs_setopt_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_get, vfs_setopts_error, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_get, return, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_prison_destructor, entry, "void *");
-LIN_SDT_PROBE_DEFINE0(mib, linux_prison_destructor, return);
-LIN_SDT_PROBE_DEFINE0(mib, linux_osd_jail_register, entry);
-LIN_SDT_PROBE_DEFINE0(mib, linux_osd_jail_register, return);
-LIN_SDT_PROBE_DEFINE0(mib, linux_osd_jail_deregister, entry);
-LIN_SDT_PROBE_DEFINE0(mib, linux_osd_jail_deregister, return);
-LIN_SDT_PROBE_DEFINE2(mib, linux_get_osname, entry, "struct thread *",
- "char *");
-LIN_SDT_PROBE_DEFINE0(mib, linux_get_osname, return);
-LIN_SDT_PROBE_DEFINE2(mib, linux_set_osname, entry, "struct thread *",
- "char *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_set_osname, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_get_osrelease, entry, "struct thread *",
- "char *");
-LIN_SDT_PROBE_DEFINE0(mib, linux_get_osrelease, return);
-LIN_SDT_PROBE_DEFINE1(mib, linux_kernver, entry, "struct thread *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_kernver, return, "int");
-LIN_SDT_PROBE_DEFINE2(mib, linux_set_osrelease, entry, "struct thread *",
- "char *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_set_osrelease, return, "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_get_oss_version, entry, "struct thread *");
-LIN_SDT_PROBE_DEFINE1(mib, linux_get_oss_version, return, "int");
-
-LIN_SDT_PROBE_DEFINE2(mib, linux_set_oss_version, entry, "struct thread *",
- "int");
-LIN_SDT_PROBE_DEFINE1(mib, linux_set_oss_version, return, "int");
-
struct linux_prison {
char pr_osname[LINUX_MAX_UTSNAME];
char pr_osrelease[LINUX_MAX_UTSNAME];
@@ -136,92 +60,70 @@ static struct linux_prison lprison0 = {
static unsigned linux_osd_jail_slot;
-static SYSCTL_NODE(_compat, OID_AUTO, LINUX_OID, CTLFLAG_RW, 0,
- "Linux mode");
+SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0, "Linux mode");
static int linux_set_osname(struct thread *td, char *osname);
static int linux_set_osrelease(struct thread *td, char *osrelease);
static int linux_set_oss_version(struct thread *td, int oss_version);
static int
-__linuxN(sysctl_osname)(SYSCTL_HANDLER_ARGS)
+linux_sysctl_osname(SYSCTL_HANDLER_ARGS)
{
char osname[LINUX_MAX_UTSNAME];
int error;
- LIN_SDT_PROBE0(mib, linux_sysctl_osname, entry);
-
linux_get_osname(req->td, osname);
error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
- if (error != 0 || req->newptr == NULL) {
- LIN_SDT_PROBE1(mib, linux_sysctl_osname, sysctl_string_error,
- error);
- LIN_SDT_PROBE1(mib, linux_sysctl_osname, return, error);
+ if (error != 0 || req->newptr == NULL)
return (error);
- }
error = linux_set_osname(req->td, osname);
- LIN_SDT_PROBE1(mib, linux_sysctl_osname, return, error);
return (error);
}
-SYSCTL_PROC(LINUX_COMPAT_OID, OID_AUTO, osname,
+SYSCTL_PROC(_compat_linux, OID_AUTO, osname,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
- 0, 0, __linuxN(sysctl_osname), "A",
+ 0, 0, linux_sysctl_osname, "A",
"Linux kernel OS name");
static int
-__linuxN(sysctl_osrelease)(SYSCTL_HANDLER_ARGS)
+linux_sysctl_osrelease(SYSCTL_HANDLER_ARGS)
{
char osrelease[LINUX_MAX_UTSNAME];
int error;
- LIN_SDT_PROBE0(mib, linux_sysctl_osrelease, entry);
-
linux_get_osrelease(req->td, osrelease);
error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
- if (error != 0 || req->newptr == NULL) {
- LIN_SDT_PROBE1(mib, linux_sysctl_osrelease, sysctl_string_error,
- error);
- LIN_SDT_PROBE1(mib, linux_sysctl_osrelease, return, error);
+ if (error != 0 || req->newptr == NULL)
return (error);
- }
error = linux_set_osrelease(req->td, osrelease);
- LIN_SDT_PROBE1(mib, linux_sysctl_osrelease, return, error);
return (error);
}
-SYSCTL_PROC(LINUX_COMPAT_OID, OID_AUTO, osrelease,
+SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease,
CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
- 0, 0, __linuxN(sysctl_osrelease), "A",
+ 0, 0, linux_sysctl_osrelease, "A",
"Linux kernel OS release");
static int
-__linuxN(sysctl_oss_version)(SYSCTL_HANDLER_ARGS)
+linux_sysctl_oss_version(SYSCTL_HANDLER_ARGS)
{
int oss_version;
int error;
- LIN_SDT_PROBE0(mib, linux_sysctl_oss_version, entry);
-
oss_version = linux_get_oss_version(req->td);
error = sysctl_handle_int(oidp, &oss_version, 0, req);
- if (error != 0 || req->newptr == NULL) {
- LIN_SDT_PROBE1(mib, linux_sysctl_oss_version,
- sysctl_string_error, error);
- LIN_SDT_PROBE1(mib, linux_sysctl_oss_version, return, error);
+ if (error != 0 || req->newptr == NULL)
return (error);
- }
error = linux_set_oss_version(req->td, oss_version);
- LIN_SDT_PROBE1(mib, linux_sysctl_oss_version, return, error);
return (error);
}
-SYSCTL_PROC(LINUX_COMPAT_OID, OID_AUTO, oss_version,
+SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
- 0, 0, __linuxN(sysctl_oss_version), "I",
+ 0, 0, linux_sysctl_oss_version, "I",
"Linux OSS version");
/*
@@ -233,37 +135,26 @@ linux_map_osrel(char *osrelease, int *os
char *sep, *eosrelease;
int len, v0, v1, v2, v;
- LIN_SDT_PROBE2(mib, linux_map_osrel, entry, osrelease, osrel);
-
len = strlen(osrelease);
eosrelease = osrelease + len;
v0 = strtol(osrelease, &sep, 10);
- if (osrelease == sep || sep + 1 >= eosrelease || *sep != '.') {
- LIN_SDT_PROBE1(mib, linux_map_osrel, return, EINVAL);
+ if (osrelease == sep || sep + 1 >= eosrelease || *sep != '.')
return (EINVAL);
- }
osrelease = sep + 1;
v1 = strtol(osrelease, &sep, 10);
- if (osrelease == sep || sep + 1 >= eosrelease || *sep != '.') {
- LIN_SDT_PROBE1(mib, linux_map_osrel, return, EINVAL);
+ if (osrelease == sep || sep + 1 >= eosrelease || *sep != '.')
return (EINVAL);
- }
osrelease = sep + 1;
v2 = strtol(osrelease, &sep, 10);
- if (osrelease == sep || sep != eosrelease) {
- LIN_SDT_PROBE1(mib, linux_map_osrel, return, EINVAL);
+ if (osrelease == sep || sep != eosrelease)
return (EINVAL);
- }
v = v0 * 1000000 + v1 * 1000 + v2;
- if (v < 1000000) {
- LIN_SDT_PROBE1(mib, linux_map_osrel, return, EINVAL);
+ if (v < 1000000)
return (EINVAL);
- }
*osrel = v;
- LIN_SDT_PROBE1(mib, linux_map_osrel, return, 0);
return (0);
}
@@ -277,8 +168,6 @@ linux_find_prison(struct prison *spr, st
struct prison *pr;
struct linux_prison *lpr;
- LIN_SDT_PROBE2(mib, linux_get_prison, entry, spr, prp);
-
if (!linux_osd_jail_slot)
/* In case osd_register failed. */
spr = &prison0;
@@ -293,7 +182,6 @@ linux_find_prison(struct prison *spr, st
}
*prp = pr;
- LIN_SDT_PROBE1(mib, linux_get_prison, return, lpr);
return (lpr);
}
@@ -308,8 +196,6 @@ linux_alloc_prison(struct prison *pr, st
struct linux_prison *lpr, *nlpr;
int error;
- LIN_SDT_PROBE2(mib, linux_alloc_prison, entry, pr, lprp);
-
/* If this prison already has Linux info, return that. */
error = 0;
lpr = linux_find_prison(pr, &ppr);
@@ -343,7 +229,6 @@ linux_alloc_prison(struct prison *pr, st
else
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_alloc_prison, return, error);
return (error);
}
@@ -355,26 +240,16 @@ linux_prison_create(void *obj, void *dat
{
struct prison *pr = obj;
struct vfsoptlist *opts = data;
- int jsys, error;
-
- LIN_SDT_PROBE2(mib, linux_prison_create, entry, obj, data);
+ int jsys;
- error = vfs_copyopt(opts, "linux", &jsys, sizeof(jsys));
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_create, vfs_copyopt_error,
- error);
- } else if (jsys == JAIL_SYS_INHERIT) {
- LIN_SDT_PROBE1(mib, linux_prison_create, return, 0);
+ if (vfs_copyopt(opts, "linux", &jsys, sizeof(jsys)) == 0 &&
+ jsys == JAIL_SYS_INHERIT)
return (0);
- }
/*
* Inherit a prison's initial values from its parent
* (different from JAIL_SYS_INHERIT which also inherits changes).
*/
- error = linux_alloc_prison(pr, NULL);
-
- LIN_SDT_PROBE1(mib, linux_prison_create, return, error);
- return (error);
+ return (linux_alloc_prison(pr, NULL));
}
static int
@@ -384,80 +259,46 @@ linux_prison_check(void *obj __unused, v
char *osname, *osrelease;
int error, jsys, len, osrel, oss_version;
- LIN_SDT_PROBE2(mib, linux_prison_check, entry, obj, data);
-
/* Check that the parameters are correct. */
error = vfs_copyopt(opts, "linux", &jsys, sizeof(jsys));
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, vfs_copyopt_error,
- error);
- }
if (error != ENOENT) {
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, error);
+ if (error != 0)
return (error);
- }
- if (jsys != JAIL_SYS_NEW && jsys != JAIL_SYS_INHERIT) {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, EINVAL);
+ if (jsys != JAIL_SYS_NEW && jsys != JAIL_SYS_INHERIT)
return (EINVAL);
- }
}
error = vfs_getopt(opts, "linux.osname", (void **)&osname, &len);
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, vfs_getopt_error,
- error);
- }
if (error != ENOENT) {
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, error);
+ if (error != 0)
return (error);
- }
- if (len == 0 || osname[len - 1] != '\0') {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, EINVAL);
+ if (len == 0 || osname[len - 1] != '\0')
return (EINVAL);
- }
if (len > LINUX_MAX_UTSNAME) {
vfs_opterror(opts, "linux.osname too long");
- LIN_SDT_PROBE1(mib, linux_prison_check, return,
- ENAMETOOLONG);
return (ENAMETOOLONG);
}
}
error = vfs_getopt(opts, "linux.osrelease", (void **)&osrelease, &len);
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, vfs_getopt_error,
- error);
- }
if (error != ENOENT) {
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, error);
+ if (error != 0)
return (error);
- }
- if (len == 0 || osrelease[len - 1] != '\0') {
- LIN_SDT_PROBE1(mib, linux_prison_check, return, EINVAL);
+ if (len == 0 || osrelease[len - 1] != '\0')
return (EINVAL);
- }
if (len > LINUX_MAX_UTSNAME) {
vfs_opterror(opts, "linux.osrelease too long");
- LIN_SDT_PROBE1(mib, linux_prison_check, return,
- ENAMETOOLONG);
return (ENAMETOOLONG);
}
error = linux_map_osrel(osrelease, &osrel);
if (error != 0) {
vfs_opterror(opts, "linux.osrelease format error");
- LIN_SDT_PROBE1(mib, linux_prison_check, return, error);
return (error);
}
}
error = vfs_copyopt(opts, "linux.oss_version", &oss_version,
sizeof(oss_version));
- if (error != 0)
- LIN_SDT_PROBE1(mib, linux_prison_check, vfs_copyopt_error, error);
if (error == ENOENT)
error = 0;
- LIN_SDT_PROBE1(mib, linux_prison_check, return, error);
return (error);
}
@@ -470,32 +311,22 @@ linux_prison_set(void *obj, void *data)
char *osname, *osrelease;
int error, gotversion, jsys, len, oss_version;
- LIN_SDT_PROBE2(mib, linux_prison_set, entry, obj, data);
-
/* Set the parameters, which should be correct. */
error = vfs_copyopt(opts, "linux", &jsys, sizeof(jsys));
- if (error != 0)
- LIN_SDT_PROBE1(mib, linux_prison_set, vfs_copyopt_error, error);
if (error == ENOENT)
jsys = -1;
error = vfs_getopt(opts, "linux.osname", (void **)&osname, &len);
- if (error != 0)
- LIN_SDT_PROBE1(mib, linux_prison_set, vfs_getopt_error, error);
if (error == ENOENT)
osname = NULL;
else
jsys = JAIL_SYS_NEW;
error = vfs_getopt(opts, "linux.osrelease", (void **)&osrelease, &len);
- if (error != 0)
- LIN_SDT_PROBE1(mib, linux_prison_set, vfs_getopt_error, error);
if (error == ENOENT)
osrelease = NULL;
else
jsys = JAIL_SYS_NEW;
error = vfs_copyopt(opts, "linux.oss_version", &oss_version,
sizeof(oss_version));
- if (error != 0)
- LIN_SDT_PROBE1(mib, linux_prison_set, vfs_copyopt_error, error);
if (error == ENOENT)
gotversion = 0;
else {
@@ -517,15 +348,12 @@ linux_prison_set(void *obj, void *data)
error = linux_alloc_prison(pr, &lpr);
if (error) {
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_prison_set, return, error);
return (error);
}
if (osrelease) {
error = linux_map_osrel(osrelease, &lpr->pr_osrel);
if (error) {
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_prison_set, return,
- error);
return (error);
}
strlcpy(lpr->pr_osrelease, osrelease,
@@ -538,19 +366,9 @@ linux_prison_set(void *obj, void *data)
mtx_unlock(&pr->pr_mtx);
}
- LIN_SDT_PROBE1(mib, linux_prison_set, return, 0);
return (0);
}
-#if defined(__amd64__) && !defined(COMPAT_LINUX32)
-SYSCTL_JAIL_PARAM_SYS_NODE(linux64, CTLFLAG_RW, "Jail Linux parameters");
-SYSCTL_JAIL_PARAM_STRING(_linux64, osname, CTLFLAG_RW, LINUX_MAX_UTSNAME,
- "Jail Linux kernel OS name");
-SYSCTL_JAIL_PARAM_STRING(_linux64, osrelease, CTLFLAG_RW, LINUX_MAX_UTSNAME,
- "Jail Linux kernel OS release");
-SYSCTL_JAIL_PARAM(_linux64, oss_version, CTLTYPE_INT | CTLFLAG_RW,
- "I", "Jail Linux OSS version");
-#else
SYSCTL_JAIL_PARAM_SYS_NODE(linux, CTLFLAG_RW, "Jail Linux parameters");
SYSCTL_JAIL_PARAM_STRING(_linux, osname, CTLFLAG_RW, LINUX_MAX_UTSNAME,
"Jail Linux kernel OS name");
@@ -558,7 +376,6 @@ SYSCTL_JAIL_PARAM_STRING(_linux, osrelea
"Jail Linux kernel OS release");
SYSCTL_JAIL_PARAM(_linux, oss_version, CTLTYPE_INT | CTLFLAG_RW,
"I", "Jail Linux OSS version");
-#endif
static int
linux_prison_get(void *obj, void *data)
@@ -571,74 +388,44 @@ linux_prison_get(void *obj, void *data)
static int version0;
- LIN_SDT_PROBE2(mib, linux_prison_get, entry, obj, data);
-
/* See if this prison is the one with the Linux info. */
lpr = linux_find_prison(pr, &ppr);
i = (ppr == pr) ? JAIL_SYS_NEW : JAIL_SYS_INHERIT;
error = vfs_setopt(opts, "linux", &i, sizeof(i));
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopt_error, error);
- if (error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
if (i) {
error = vfs_setopts(opts, "linux.osname", lpr->pr_osname);
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopts_error,
- error);
- if (error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
error = vfs_setopts(opts, "linux.osrelease", lpr->pr_osrelease);
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopts_error,
- error);
- if (error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
error = vfs_setopt(opts, "linux.oss_version",
&lpr->pr_oss_version, sizeof(lpr->pr_oss_version));
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopt_error,
- error);
- if(error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
} else {
/*
* If this prison is inheriting its Linux info, report
* empty/zero parameters.
*/
error = vfs_setopts(opts, "linux.osname", "");
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopts_error,
- error);
- if(error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
error = vfs_setopts(opts, "linux.osrelease", "");
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopts_error,
- error);
- if(error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
error = vfs_setopt(opts, "linux.oss_version", &version0,
sizeof(lpr->pr_oss_version));
- if (error != 0) {
- LIN_SDT_PROBE1(mib, linux_prison_get, vfs_setopt_error,
- error);
- if(error != ENOENT)
- goto done;
- }
+ if (error != 0 && error != ENOENT)
+ goto done;
}
error = 0;
done:
mtx_unlock(&ppr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_prison_get, return, error);
return (error);
}
@@ -646,9 +433,7 @@ static void
linux_prison_destructor(void *data)
{
- LIN_SDT_PROBE1(mib, linux_prison_destructor, entry, data);
free(data, M_PRISON);
- LIN_SDT_PROBE0(mib, linux_prison_destructor, return);
}
void
@@ -662,8 +447,6 @@ linux_osd_jail_register(void)
[PR_METHOD_CHECK] = linux_prison_check
};
- LIN_SDT_PROBE0(mib, linux_osd_jail_register, entry);
-
linux_osd_jail_slot =
osd_jail_register(linux_prison_destructor, methods);
if (linux_osd_jail_slot > 0) {
@@ -673,20 +456,14 @@ linux_osd_jail_register(void)
(void)linux_alloc_prison(pr, NULL);
sx_xunlock(&allprison_lock);
}
-
- LIN_SDT_PROBE0(mib, linux_osd_jail_register, return);
}
void
linux_osd_jail_deregister(void)
{
- LIN_SDT_PROBE0(mib, linux_osd_jail_register, entry);
-
if (linux_osd_jail_slot)
osd_jail_deregister(linux_osd_jail_slot);
-
- LIN_SDT_PROBE0(mib, linux_osd_jail_register, return);
}
void
@@ -695,13 +472,9 @@ linux_get_osname(struct thread *td, char
struct prison *pr;
struct linux_prison *lpr;
- LIN_SDT_PROBE2(mib, linux_get_osname, entry, td, dst);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
bcopy(lpr->pr_osname, dst, LINUX_MAX_UTSNAME);
mtx_unlock(&pr->pr_mtx);
-
- LIN_SDT_PROBE0(mib, linux_get_osname, return);
}
static int
@@ -710,13 +483,10 @@ linux_set_osname(struct thread *td, char
struct prison *pr;
struct linux_prison *lpr;
- LIN_SDT_PROBE2(mib, linux_set_osname, entry, td, osname);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
strlcpy(lpr->pr_osname, osname, LINUX_MAX_UTSNAME);
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_set_osname, return, 0);
return (0);
}
@@ -726,13 +496,9 @@ linux_get_osrelease(struct thread *td, c
struct prison *pr;
struct linux_prison *lpr;
- LIN_SDT_PROBE2(mib, linux_get_osrelease, entry, td, dst);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
bcopy(lpr->pr_osrelease, dst, LINUX_MAX_UTSNAME);
mtx_unlock(&pr->pr_mtx);
-
- LIN_SDT_PROBE0(mib, linux_get_osrelease, return);
}
int
@@ -742,13 +508,10 @@ linux_kernver(struct thread *td)
struct linux_prison *lpr;
int osrel;
- LIN_SDT_PROBE1(mib, linux_kernver, entry, td);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
osrel = lpr->pr_osrel;
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_kernver, return, osrel);
return (osrel);
}
@@ -759,15 +522,12 @@ linux_set_osrelease(struct thread *td, c
struct linux_prison *lpr;
int error;
- LIN_SDT_PROBE2(mib, linux_set_osrelease, entry, td, osrelease);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
error = linux_map_osrel(osrelease, &lpr->pr_osrel);
if (error == 0)
strlcpy(lpr->pr_osrelease, osrelease, LINUX_MAX_UTSNAME);
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_set_osrelease, return, error);
return (error);
}
@@ -778,13 +538,10 @@ linux_get_oss_version(struct thread *td)
struct linux_prison *lpr;
int version;
- LIN_SDT_PROBE1(mib, linux_get_oss_version, entry, td);
-
lpr = linux_find_prison(td->td_ucred->cr_prison, &pr);
version = lpr->pr_oss_version;
mtx_unlock(&pr->pr_mtx);
- LIN_SDT_PROBE1(mib, linux_get_oss_version, return, version);
return (version);
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list