summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>1999-08-27 19:47:41 +0000
committermarcel <marcel@FreeBSD.org>1999-08-27 19:47:41 +0000
commit421ba20de2168eca011b02a722a39a50edbcc3bb (patch)
treee76e287183d035dafec15693fbd1edc52428cd1e
parent10d7165e451a9b3103b41e843fd883bc9f69e7bc (diff)
downloadFreeBSD-src-421ba20de2168eca011b02a722a39a50edbcc3bb.zip
FreeBSD-src-421ba20de2168eca011b02a722a39a50edbcc3bb.tar.gz
Add sysctl variables for the Linuxulator. These reside under `compat.linux' as
discussed on current. The following variables are defined (for now): osname (defaults to "Linux") Allow users to change the name of the OS as returned by uname(2), specially added for all those Linux Netscape users and statistics maniacs :-) We now have what we all wanted! osrelease (defaults to "2.2.5") Allow users to change the version of the OS as returned by uname(2). Since -current supports glibc2.1 now, change the default to 2.2.5 (was 2.0.36). oss_version (defaults to 198144 [0x030600]) This one will be used by the OSS_GETVERSION ioctl (PR 12917) which I can commit now that we have the MIB. The default version number is the lowest version possible with the current 'encoding'. A note about imprisoned processes (see jail(2)): These variables are copy-on-write (as suggested by phk). This means that imprisoned processes will use the system wide value unless it is written/set by the process. From that moment on, a copy local to the prison will be used. A note about the implementation: I choose to add a single pointer to struct prison, because I didn't like the idea of changing struct prison every time I come up with a new variable. As a side effect, the extra storage is only needed when a variable is set from within the prison. This also minimizes kernel bloat when the Linuxulator is not used; both compiled in or as a module. Reviewed by: bde (first version only) and phk
-rw-r--r--sys/compat/linux/linux_mib.c231
-rw-r--r--sys/compat/linux/linux_mib.h43
-rw-r--r--sys/compat/linux/linux_misc.c11
-rw-r--r--sys/conf/files.i3863
-rw-r--r--sys/i386/conf/files.i3863
-rw-r--r--sys/i386/linux/linux_mib.c231
-rw-r--r--sys/i386/linux/linux_mib.h43
-rw-r--r--sys/i386/linux/linux_misc.c11
-rw-r--r--sys/kern/kern_exit.c7
-rw-r--r--sys/kern/kern_mib.c6
-rw-r--r--sys/modules/linux/Makefile4
-rw-r--r--sys/sys/jail.h3
-rw-r--r--sys/sys/sysctl.h3
13 files changed, 583 insertions, 16 deletions
diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c
new file mode 100644
index 0000000..98b4a94f
--- /dev/null
+++ b/sys/compat/linux/linux_mib.c
@@ -0,0 +1,231 @@
+/*-
+ * Copyright (c) 1999 Marcel Moolenaar
+ * 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
+ * in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/jail.h>
+
+#include <i386/linux/linux.h>
+#include <i386/linux/linux_mib.h>
+
+struct linux_prison {
+ char pr_osname[LINUX_MAX_UTSNAME];
+ char pr_osrelease[LINUX_MAX_UTSNAME];
+ int pr_oss_version;
+};
+
+SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0,
+ "Linux mode");
+
+static char linux_osname[LINUX_MAX_UTSNAME] = "Linux";
+
+static int
+linux_sysctl_osname SYSCTL_HANDLER_ARGS
+{
+ char osname[LINUX_MAX_UTSNAME];
+ int error;
+
+ strcpy(osname, linux_get_osname(req->p));
+ error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_osname(req->p, osname);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, osname,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_osname, "A",
+ "Linux kernel OS name");
+
+static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.2.5";
+
+static int
+linux_sysctl_osrelease SYSCTL_HANDLER_ARGS
+{
+ char osrelease[LINUX_MAX_UTSNAME];
+ int error;
+
+ strcpy(osrelease, linux_get_osrelease(req->p));
+ error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_osrelease(req->p, osrelease);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_osrelease, "A",
+ "Linux kernel OS release");
+
+static int linux_oss_version = 0x030600;
+
+static int
+linux_sysctl_oss_version SYSCTL_HANDLER_ARGS
+{
+ int oss_version;
+ int error;
+
+ oss_version = linux_get_oss_version(req->p);
+ error = sysctl_handle_int(oidp, &oss_version, 0, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_oss_version(req->p, oss_version);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version,
+ CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_oss_version, "I",
+ "Linux OSS version");
+
+static struct linux_prison *
+get_prison(struct proc *p)
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr == NULL)
+ return (NULL);
+
+ if (pr->pr_linux == NULL) {
+ MALLOC(lpr, struct linux_prison *, sizeof *lpr,
+ M_PRISON, M_WAITOK);
+ bzero((caddr_t)lpr, sizeof *lpr);
+ pr->pr_linux = lpr;
+ }
+
+ return (pr->pr_linux);
+}
+
+char *
+linux_get_osname(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_osname[0])
+ return (lpr->pr_osname);
+ }
+
+ return (linux_osname);
+}
+
+int
+linux_set_osname(p, osname)
+ struct proc *p;
+ char *osname;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ strcpy(lpr->pr_osname, osname);
+ else
+ strcpy(linux_osname, osname);
+
+ return (0);
+}
+
+char *
+linux_get_osrelease(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_osrelease[0])
+ return (lpr->pr_osrelease);
+ }
+
+ return (linux_osrelease);
+}
+
+int
+linux_set_osrelease(p, osrelease)
+ struct proc *p;
+ char *osrelease;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ strcpy(lpr->pr_osrelease, osrelease);
+ else
+ strcpy(linux_osrelease, osrelease);
+
+ return (0);
+}
+
+int
+linux_get_oss_version(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_oss_version)
+ return (lpr->pr_oss_version);
+ }
+
+ return (linux_oss_version);
+}
+
+int
+linux_set_oss_version(p, oss_version)
+ struct proc *p;
+ int oss_version;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ lpr->pr_oss_version = oss_version;
+ else
+ linux_oss_version = oss_version;
+
+ return (0);
+}
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
new file mode 100644
index 0000000..24c2548
--- /dev/null
+++ b/sys/compat/linux/linux_mib.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1999 Marcel Moolenaar
+ * 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
+ * in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ * $Id$
+ */
+
+#ifndef _LINUX_MIB_H_
+#define _LINUX_MIB_H_
+
+char* linux_get_osname __P((struct proc *p));
+int linux_set_osname __P((struct proc *p, char *osname));
+
+char* linux_get_osrelease __P((struct proc *p));
+int linux_set_osrelease __P((struct proc *p, char *osrelease));
+
+int linux_get_oss_version __P((struct proc *p));
+int linux_set_oss_version __P((struct proc *p, int oss_version));
+
+#endif /* _LINUX_MIB_H_ */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 929bfaa..74fb731 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: linux_misc.c,v 1.66 1999/08/25 11:19:02 marcel Exp $
+ * $Id: linux_misc.c,v 1.67 1999/08/25 14:11:01 marcel Exp $
*/
#include "opt_compat.h"
@@ -61,6 +61,7 @@
#include <i386/linux/linux.h>
#include <i386/linux/linux_proto.h>
#include <i386/linux/linux_util.h>
+#include <i386/linux/linux_mib.h>
#include <posix4/sched.h>
@@ -880,15 +881,19 @@ int
linux_newuname(struct proc *p, struct linux_newuname_args *args)
{
struct linux_new_utsname utsname;
+ char *osrelease, *osname;
#ifdef DEBUG
printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
#endif
+ osname = linux_get_osname(p);
+ osrelease = linux_get_osrelease(p);
+
bzero(&utsname, sizeof(struct linux_new_utsname));
- strncpy(utsname.sysname, "Linux", LINUX_MAX_UTSNAME-1);
+ strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.release, "2.0.36", LINUX_MAX_UTSNAME-1);
+ strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1);
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 62e3269..7234965 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $Id: files.i386,v 1.258 1999/08/09 10:34:38 phk Exp $
+# $Id: files.i386,v 1.259 1999/08/18 04:08:14 alc Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -329,6 +329,7 @@ i386/linux/linux_ioctl.c optional compat_linux
i386/linux/linux_ipc.c optional compat_linux
i386/linux/linux_locore.s optional compat_linux \
dependency "linux_assym.h"
+i386/linux/linux_mib.c optional compat_linux
i386/linux/linux_misc.c optional compat_linux
i386/linux/linux_signal.c optional compat_linux
i386/linux/linux_socket.c optional compat_linux
diff --git a/sys/i386/conf/files.i386 b/sys/i386/conf/files.i386
index 62e3269..7234965 100644
--- a/sys/i386/conf/files.i386
+++ b/sys/i386/conf/files.i386
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $Id: files.i386,v 1.258 1999/08/09 10:34:38 phk Exp $
+# $Id: files.i386,v 1.259 1999/08/18 04:08:14 alc Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -329,6 +329,7 @@ i386/linux/linux_ioctl.c optional compat_linux
i386/linux/linux_ipc.c optional compat_linux
i386/linux/linux_locore.s optional compat_linux \
dependency "linux_assym.h"
+i386/linux/linux_mib.c optional compat_linux
i386/linux/linux_misc.c optional compat_linux
i386/linux/linux_signal.c optional compat_linux
i386/linux/linux_socket.c optional compat_linux
diff --git a/sys/i386/linux/linux_mib.c b/sys/i386/linux/linux_mib.c
new file mode 100644
index 0000000..98b4a94f
--- /dev/null
+++ b/sys/i386/linux/linux_mib.c
@@ -0,0 +1,231 @@
+/*-
+ * Copyright (c) 1999 Marcel Moolenaar
+ * 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
+ * in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/jail.h>
+
+#include <i386/linux/linux.h>
+#include <i386/linux/linux_mib.h>
+
+struct linux_prison {
+ char pr_osname[LINUX_MAX_UTSNAME];
+ char pr_osrelease[LINUX_MAX_UTSNAME];
+ int pr_oss_version;
+};
+
+SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0,
+ "Linux mode");
+
+static char linux_osname[LINUX_MAX_UTSNAME] = "Linux";
+
+static int
+linux_sysctl_osname SYSCTL_HANDLER_ARGS
+{
+ char osname[LINUX_MAX_UTSNAME];
+ int error;
+
+ strcpy(osname, linux_get_osname(req->p));
+ error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_osname(req->p, osname);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, osname,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_osname, "A",
+ "Linux kernel OS name");
+
+static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.2.5";
+
+static int
+linux_sysctl_osrelease SYSCTL_HANDLER_ARGS
+{
+ char osrelease[LINUX_MAX_UTSNAME];
+ int error;
+
+ strcpy(osrelease, linux_get_osrelease(req->p));
+ error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_osrelease(req->p, osrelease);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_osrelease, "A",
+ "Linux kernel OS release");
+
+static int linux_oss_version = 0x030600;
+
+static int
+linux_sysctl_oss_version SYSCTL_HANDLER_ARGS
+{
+ int oss_version;
+ int error;
+
+ oss_version = linux_get_oss_version(req->p);
+ error = sysctl_handle_int(oidp, &oss_version, 0, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ error = linux_set_oss_version(req->p, oss_version);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version,
+ CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON,
+ 0, 0, linux_sysctl_oss_version, "I",
+ "Linux OSS version");
+
+static struct linux_prison *
+get_prison(struct proc *p)
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr == NULL)
+ return (NULL);
+
+ if (pr->pr_linux == NULL) {
+ MALLOC(lpr, struct linux_prison *, sizeof *lpr,
+ M_PRISON, M_WAITOK);
+ bzero((caddr_t)lpr, sizeof *lpr);
+ pr->pr_linux = lpr;
+ }
+
+ return (pr->pr_linux);
+}
+
+char *
+linux_get_osname(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_osname[0])
+ return (lpr->pr_osname);
+ }
+
+ return (linux_osname);
+}
+
+int
+linux_set_osname(p, osname)
+ struct proc *p;
+ char *osname;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ strcpy(lpr->pr_osname, osname);
+ else
+ strcpy(linux_osname, osname);
+
+ return (0);
+}
+
+char *
+linux_get_osrelease(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_osrelease[0])
+ return (lpr->pr_osrelease);
+ }
+
+ return (linux_osrelease);
+}
+
+int
+linux_set_osrelease(p, osrelease)
+ struct proc *p;
+ char *osrelease;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ strcpy(lpr->pr_osrelease, osrelease);
+ else
+ strcpy(linux_osrelease, osrelease);
+
+ return (0);
+}
+
+int
+linux_get_oss_version(p)
+ struct proc *p;
+{
+ register struct prison *pr;
+ register struct linux_prison *lpr;
+
+ pr = p->p_prison;
+ if (pr != NULL && pr->pr_linux != NULL) {
+ lpr = pr->pr_linux;
+ if (lpr->pr_oss_version)
+ return (lpr->pr_oss_version);
+ }
+
+ return (linux_oss_version);
+}
+
+int
+linux_set_oss_version(p, oss_version)
+ struct proc *p;
+ int oss_version;
+{
+ register struct linux_prison *lpr;
+
+ lpr = get_prison(p);
+ if (lpr != NULL)
+ lpr->pr_oss_version = oss_version;
+ else
+ linux_oss_version = oss_version;
+
+ return (0);
+}
diff --git a/sys/i386/linux/linux_mib.h b/sys/i386/linux/linux_mib.h
new file mode 100644
index 0000000..24c2548
--- /dev/null
+++ b/sys/i386/linux/linux_mib.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1999 Marcel Moolenaar
+ * 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
+ * in this position and unchanged.
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ *
+ * $Id$
+ */
+
+#ifndef _LINUX_MIB_H_
+#define _LINUX_MIB_H_
+
+char* linux_get_osname __P((struct proc *p));
+int linux_set_osname __P((struct proc *p, char *osname));
+
+char* linux_get_osrelease __P((struct proc *p));
+int linux_set_osrelease __P((struct proc *p, char *osrelease));
+
+int linux_get_oss_version __P((struct proc *p));
+int linux_set_oss_version __P((struct proc *p, int oss_version));
+
+#endif /* _LINUX_MIB_H_ */
diff --git a/sys/i386/linux/linux_misc.c b/sys/i386/linux/linux_misc.c
index 929bfaa..74fb731 100644
--- a/sys/i386/linux/linux_misc.c
+++ b/sys/i386/linux/linux_misc.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: linux_misc.c,v 1.66 1999/08/25 11:19:02 marcel Exp $
+ * $Id: linux_misc.c,v 1.67 1999/08/25 14:11:01 marcel Exp $
*/
#include "opt_compat.h"
@@ -61,6 +61,7 @@
#include <i386/linux/linux.h>
#include <i386/linux/linux_proto.h>
#include <i386/linux/linux_util.h>
+#include <i386/linux/linux_mib.h>
#include <posix4/sched.h>
@@ -880,15 +881,19 @@ int
linux_newuname(struct proc *p, struct linux_newuname_args *args)
{
struct linux_new_utsname utsname;
+ char *osrelease, *osname;
#ifdef DEBUG
printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
#endif
+ osname = linux_get_osname(p);
+ osrelease = linux_get_osrelease(p);
+
bzero(&utsname, sizeof(struct linux_new_utsname));
- strncpy(utsname.sysname, "Linux", LINUX_MAX_UTSNAME-1);
+ strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.release, "2.0.36", LINUX_MAX_UTSNAME-1);
+ strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 91a7461..10a54ac 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
- * $Id: kern_exit.c,v 1.80 1999/04/28 11:36:52 phk Exp $
+ * $Id: kern_exit.c,v 1.81 1999/06/07 20:37:29 msmith Exp $
*/
#include "opt_compat.h"
@@ -508,8 +508,11 @@ loop:
/*
* Destroy empty prisons
*/
- if (p->p_prison && !--p->p_prison->pr_ref)
+ if (p->p_prison && !--p->p_prison->pr_ref) {
+ if (p->p_prison->pr_linux != NULL)
+ FREE(p->p_prison->pr_linux, M_PRISON);
FREE(p->p_prison, M_PRISON);
+ }
/*
* Finally finished with old proc entry.
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c
index d9e9250..aa69b24 100644
--- a/sys/kern/kern_mib.c
+++ b/sys/kern/kern_mib.c
@@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
- * $Id: kern_mib.c,v 1.22 1999/07/20 07:19:32 phk Exp $
+ * $Id: kern_mib.c,v 1.23 1999/08/08 18:42:48 phk Exp $
*/
#include <sys/param.h>
@@ -72,10 +72,12 @@ SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0,
"machine dependent");
SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0,
"user-level");
-
SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0,
"p1003_1b, (see p1003_1b.h)");
+SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0,
+ "Compatibility code");
+
SYSCTL_NODE(_kern, OID_AUTO, prison, CTLFLAG_RW, 0,
"Prison rules");
diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile
index e6328ac..72485f0 100644
--- a/sys/modules/linux/Makefile
+++ b/sys/modules/linux/Makefile
@@ -1,9 +1,9 @@
-# $Id: Makefile,v 1.24 1998/11/12 00:37:39 jkh Exp $
+# $Id: Makefile,v 1.25 1999/01/26 21:29:01 julian Exp $
.PATH: ${.CURDIR}/../../i386/linux
KMOD= linux
SRCS= linux_file.c linux_ioctl.c linux_misc.c linux_signal.c \
- linux_ipc.c linux_socket.c linux_stats.c \
+ linux_ipc.c linux_socket.c linux_stats.c linux_mib.c \
linux_dummy.c linux_sysent.c linux_sysvec.c linux_util.c \
imgact_linux.c opt_compat.h opt_linux.h opt_vmpage.h vnode_if.h
OBJS= linux_locore.o
diff --git a/sys/sys/jail.h b/sys/sys/jail.h
index aae7142..ca6fb94 100644
--- a/sys/sys/jail.h
+++ b/sys/sys/jail.h
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: jail.h,v 1.1 1999/04/28 11:38:03 phk Exp $
+ * $Id: jail.h,v 1.2 1999/05/16 10:51:52 phk Exp $
*
*/
@@ -39,6 +39,7 @@ struct prison {
int pr_ref;
char pr_host[MAXHOSTNAMELEN];
u_int32_t pr_ip;
+ void *pr_linux;
};
#endif /* !KERNEL */
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 0f949d8..c401115 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)sysctl.h 8.1 (Berkeley) 6/2/93
- * $Id: sysctl.h,v 1.72 1999/02/28 17:38:28 dt Exp $
+ * $Id: sysctl.h,v 1.73 1999/04/28 11:38:10 phk Exp $
*/
#ifndef _SYS_SYSCTL_H_
@@ -481,6 +481,7 @@ SYSCTL_DECL(_debug);
SYSCTL_DECL(_hw);
SYSCTL_DECL(_machdep);
SYSCTL_DECL(_user);
+SYSCTL_DECL(_compat);
extern char machine[];
extern char osrelease[];
OpenPOWER on IntegriCloud