From 2cdaa499449b8fb648a58685085560b789256d3f Mon Sep 17 00:00:00 2001 From: mrg Date: Fri, 23 Mar 2007 04:16:13 +0000 Subject: [PATCH] implement emul.linux.kern.machine, which can be set to "i686", like some applications seem to want. --- sys/compat/linux/common/linux_misc.c | 10 +++------- sys/compat/linux/common/linux_oldolduname.c | 6 +++--- sys/compat/linux/common/linux_olduname.c | 6 +++--- sys/compat/linux/common/linux_sysctl.c | 15 +++++++++++++-- sys/compat/linux/common/linux_types.h | 3 ++- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index c7a1adf2afb1..392188292d36 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.168 2007/03/14 12:44:39 njoly Exp $ */ +/* $NetBSD: linux_misc.c,v 1.169 2007/03/23 04:16:13 mrg Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.168 2007/03/14 12:44:39 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.169 2007/03/23 04:16:13 mrg Exp $"); #if defined(_KERNEL_OPT) #include "opt_ptrace.h" @@ -462,11 +462,7 @@ linux_sys_uname(struct lwp *l, void *v, register_t *retval) strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strncpy(luts.l_release, linux_release, sizeof(luts.l_release)); strncpy(luts.l_version, linux_version, sizeof(luts.l_version)); -# ifdef LINUX_UNAME_ARCH - strncpy(luts.l_machine, LINUX_UNAME_ARCH, sizeof(luts.l_machine)); -# else - strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); -# endif + strncpy(luts.l_machine, linux_machine, sizeof(luts.l_machine)); strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname)); return copyout(&luts, SCARG(uap, up), sizeof(luts)); diff --git a/sys/compat/linux/common/linux_oldolduname.c b/sys/compat/linux/common/linux_oldolduname.c index b6ceac2653c9..414cf8928421 100644 --- a/sys/compat/linux/common/linux_oldolduname.c +++ b/sys/compat/linux/common/linux_oldolduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldolduname.c,v 1.61 2007/02/09 21:55:19 ad Exp $ */ +/* $NetBSD: linux_oldolduname.c,v 1.62 2007/03/23 04:16:13 mrg Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_oldolduname.c,v 1.61 2007/02/09 21:55:19 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_oldolduname.c,v 1.62 2007/03/23 04:16:13 mrg Exp $"); #include #include @@ -69,7 +69,7 @@ linux_sys_oldolduname(struct lwp *l, void *v, strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strncpy(luts.l_release, linux_release, sizeof(luts.l_release)); strncpy(luts.l_version, linux_version, sizeof(luts.l_version)); - strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); + strncpy(luts.l_machine, linux_machine, sizeof(luts.l_machine)); return copyout(&luts, SCARG(uap, up), sizeof(luts)); } diff --git a/sys/compat/linux/common/linux_olduname.c b/sys/compat/linux/common/linux_olduname.c index b0bff614ca2f..b5626675bae0 100644 --- a/sys/compat/linux/common/linux_olduname.c +++ b/sys/compat/linux/common/linux_olduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_olduname.c,v 1.61 2007/02/09 21:55:19 ad Exp $ */ +/* $NetBSD: linux_olduname.c,v 1.62 2007/03/23 04:16:13 mrg Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_olduname.c,v 1.61 2007/02/09 21:55:19 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_olduname.c,v 1.62 2007/03/23 04:16:13 mrg Exp $"); #include #include @@ -71,7 +71,7 @@ linux_sys_olduname(struct lwp *l, void *v, register_t *retval) strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename)); strncpy(luts.l_release, linux_release, sizeof(luts.l_release)); strncpy(luts.l_version, linux_version, sizeof(luts.l_version)); - strncpy(luts.l_machine, machine, sizeof(luts.l_machine)); + strncpy(luts.l_machine, linux_machine, sizeof(luts.l_machine)); return copyout(&luts, SCARG(uap, up), sizeof(luts)); } diff --git a/sys/compat/linux/common/linux_sysctl.c b/sys/compat/linux/common/linux_sysctl.c index 11de92412404..8b51168875cf 100644 --- a/sys/compat/linux/common/linux_sysctl.c +++ b/sys/compat/linux/common/linux_sysctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sysctl.c,v 1.25 2007/02/09 21:55:19 ad Exp $ */ +/* $NetBSD: linux_sysctl.c,v 1.26 2007/03/23 04:16:13 mrg Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.25 2007/02/09 21:55:19 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sysctl.c,v 1.26 2007/03/23 04:16:13 mrg Exp $"); #if defined (_KERNEL_OPT) #include "opt_ktrace.h" @@ -73,6 +73,7 @@ char linux_version[128] = "#0 Wed Feb 20 20:00:02 CET 2002"; char linux_release[128] = "2.0.38"; char linux_version[128] = "#0 Sun Nov 11 11:11:11 MET 2000"; #endif +char linux_machine[128] = ""; #ifndef _LKM static @@ -114,6 +115,16 @@ SYSCTL_SETUP(linux_sysctl_setup, "linux emulated sysctl subtree setup") NULL, 0, linux_version, sizeof(linux_version), LINUX_KERN_VERSION, CTL_EOL); +#ifndef LINUX_UNAME_ARCH +#define LINUX_UNAME_ARCH machine +#endif + strlcpy(linux_machine, LINUX_UNAME_ARCH, sizeof(linux_machine)); + sysctl_createv(clog, 0, &node, NULL, + CTLFLAG_PERMANENT, + CTLTYPE_STRING, "machine", NULL, + NULL, 0, linux_machine, sizeof(linux_machine), + LINUX_KERN_VERSION, CTL_EOL); + linux_sysctl_root.sysctl_flags &= ~CTLFLAG_READWRITE; } diff --git a/sys/compat/linux/common/linux_types.h b/sys/compat/linux/common/linux_types.h index d495cfbdca43..b2c99eabc4ed 100644 --- a/sys/compat/linux/common/linux_types.h +++ b/sys/compat/linux/common/linux_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_types.h,v 1.25 2007/03/14 12:44:40 njoly Exp $ */ +/* $NetBSD: linux_types.h,v 1.26 2007/03/23 04:16:14 mrg Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -80,6 +80,7 @@ struct linux_utsname { extern char linux_sysname[]; extern char linux_release[]; extern char linux_version[]; +extern char linux_machine[]; struct linux_tms { linux_clock_t ltms_utime;