Subject: uname(2) results & COMPAT_OSF1
To: NetBSD alpha <port-alpha@NetBSD.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: port-alpha
Date: 04/06/2006 15:45:23
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
While playing with COMPAT_OSF1 on a PWS500au running -current, i
noticed that uname(2) syscall does not report correct values ...
njoly@thanos [emul/osf1]> uname -a
NetBSD thanos.sis.pasteur.fr 3.99.17 NetBSD 3.99.17 (THANOS) #20: Thu Apr 6 15:01:49 CEST 2006 njoly@thanos.sis.pasteur.fr:/local/src/NetBSD/obj/alpha/sys/arch/alpha/compile/THANOS alpha
njoly@thanos [emul/osf1]> file ./uname
./uname: COFF format alpha executable paged dynamically linked stripped - version 3.13-14
njoly@thanos [emul/osf1]> ./uname -a
NetBSD thanos.sis.pasteur.fr 3.99.16 THANOS#0 alpha
The same binary run on another PWS500au with Tru64 Unix v5.1B report :
njoly@medusa [~]> ./uname -a
OSF1 medusa.sis.pasteur.fr V5.1 2650 alpha
I just modifed that part of the OSF1 compat code to give better
results. Following the Linux compat code, i added a sysctl `emul.osf1'
subtree :
njoly@thanos [~]> sysctl emul.osf1
emul.osf1.kern.ostype = OSF1
emul.osf1.kern.osrelease = V5.1
emul.osf1.kern.osversion = 2650
and then, filled the uname(2) and sysinfo(2) with the new values.
njoly@thanos [emul/osf1]> ./uname -a
OSF1 thanos.sis.pasteur.fr V5.1 2650 alpha
njoly@thanos [emul/osf1]> sudo sysctl -w emul.osf1.kern.ostype=Tru64
emul.osf1.kern.ostype: OSF1 -> Tru64
njoly@thanos [emul/osf1]> ./uname -a
Tru64 thanos.sis.pasteur.fr V5.1 2650 alpha
Comments ?
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="netbsd-osf1uname.diff"
? sys/arch/alpha/conf/THANOS
Index: sys/compat/osf1/files.osf1
===================================================================
RCS file: /cvsroot/src/sys/compat/osf1/files.osf1,v
retrieving revision 1.18
diff -u -r1.18 files.osf1
--- sys/compat/osf1/files.osf1 31 Mar 2002 22:22:48 -0000 1.18
+++ sys/compat/osf1/files.osf1 6 Apr 2006 13:14:25 -0000
@@ -31,5 +31,6 @@
file compat/osf1/osf1_resource.c compat_osf1
file compat/osf1/osf1_signal.c compat_osf1
file compat/osf1/osf1_socket.c compat_osf1
+file compat/osf1/osf1_sysctl.c compat_osf1
file compat/osf1/osf1_sysv_ipc.c compat_osf1
file compat/osf1/osf1_time.c compat_osf1
Index: sys/compat/osf1/osf1_exec.h
===================================================================
RCS file: /cvsroot/src/sys/compat/osf1/osf1_exec.h,v
retrieving revision 1.10
diff -u -r1.10 osf1_exec.h
--- sys/compat/osf1/osf1_exec.h 11 Dec 2005 12:20:23 -0000 1.10
+++ sys/compat/osf1/osf1_exec.h 6 Apr 2006 13:14:25 -0000
@@ -35,6 +35,30 @@
#define _OSF1_EXEC_H
#define OSF1_MAX_AUX_ENTRIES 4 /* max we'll ever push (right now) */
+/*
+ * Emulation specific sysctls.
+ */
+#define EMUL_OSF1_KERN 1
+#define EMUL_OSF1_MAXID 2
+
+#define EMUL_OSF1_NAMES { \
+ { 0, 0 }, \
+ { "kern", CTLTYPE_NODE }, \
+}
+
+#define EMUL_OSF1_KERN_OSTYPE 1
+#define EMUL_OSF1_KERN_OSRELEASE 2
+#define EMUL_OSF1_KERN_OSVERSION 3
+#define EMUL_OSF1_KERN_MAXID 4
+
+#define EMUL_OSF1_KERN_NAMES { \
+ { 0, 0 }, \
+ { "ostype", CTLTYPE_STRING }, \
+ { "osrelease", CTLTYPE_STRING }, \
+ { "osversion", CTLTYPE_STRING }, \
+}
+
+
extern const struct emul emul_osf1;
int osf1_exec_ecoff_probe __P((struct lwp *, struct exec_package *));
Index: sys/compat/osf1/osf1_misc.c
===================================================================
RCS file: /cvsroot/src/sys/compat/osf1/osf1_misc.c,v
retrieving revision 1.72
diff -u -r1.72 osf1_misc.c
--- sys/compat/osf1/osf1_misc.c 5 Apr 2006 15:30:48 -0000 1.72
+++ sys/compat/osf1/osf1_misc.c 6 Apr 2006 13:14:25 -0000
@@ -102,6 +102,10 @@
extern int scdebug;
#endif
+extern char osf1_sysname[];
+extern char osf1_release[];
+extern char osf1_version[];
+
int
osf1_sys_classcntl(l, v, retval)
struct lwp *l;
@@ -294,7 +298,7 @@
error = 0;
switch (SCARG(uap, cmd)) {
case OSF1_SI_SYSNAME:
- string = ostype;
+ string = osf1_sysname;
break;
case OSF1_SI_HOSTNAME:
@@ -302,11 +306,12 @@
break;
case OSF1_SI_RELEASE:
- string = osrelease;
+ string = osf1_release;
break;
case OSF1_SI_VERSION:
- goto should_handle;
+ string = osf1_version;
+ break;
case OSF1_SI_MACHINE:
string = MACHINE;
@@ -362,26 +367,15 @@
{
struct osf1_sys_uname_args *uap = v;
struct osf1_utsname u;
- const char *cp;
- char *dp, *ep;
/* XXX would use stackgap, but our struct utsname is too big! */
- strncpy(u.sysname, ostype, sizeof(u.sysname));
+ strncpy(u.sysname, osf1_sysname, sizeof(u.sysname));
strncpy(u.nodename, hostname, sizeof(u.nodename));
- strncpy(u.release, osrelease, sizeof(u.release));
- dp = u.version;
- ep = &u.version[sizeof(u.version) - 1];
- for (cp = version; *cp && *cp != '('; cp++)
- ;
- for (cp++; *cp && *cp != ')' && dp < ep; cp++)
- *dp++ = *cp;
- for (; *cp && *cp != '#'; cp++)
- ;
- for (; *cp && *cp != ':' && dp < ep; cp++)
- *dp++ = *cp;
- *dp = '\0';
+ strncpy(u.release, osf1_release, sizeof(u.release));
+ strncpy(u.version, osf1_version, sizeof(u.version));
strncpy(u.machine, MACHINE, sizeof(u.machine));
+
return (copyout((caddr_t)&u, (caddr_t)SCARG(uap, name), sizeof u));
}
Index: sys/compat/osf1/osf1_sysctl.c
===================================================================
RCS file: sys/compat/osf1/osf1_sysctl.c
diff -N sys/compat/osf1/osf1_sysctl.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sys/compat/osf1/osf1_sysctl.c 6 Apr 2006 13:14:25 -0000
@@ -0,0 +1,96 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Brown.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 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$");
+
+#include <sys/param.h>
+#include <sys/signal.h>
+#include <sys/sysctl.h>
+
+#include <compat/osf1/osf1_exec.h>
+
+char osf1_sysname[128] = "OSF1";
+char osf1_release[128] = "V5.1";
+char osf1_version[128] = "2650";
+
+char osf1_vendor[128] = "Compaq Computer Corporation";
+
+SYSCTL_SETUP(sysctl_emul_osf1_setup, "sysctl emul.osf1 subtree setup")
+{
+
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "emul", NULL,
+ NULL, 0, NULL, 0,
+ CTL_EMUL, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "osf1",
+ SYSCTL_DESCR("OSF1 emulation settings"),
+ NULL, 0, NULL, 0,
+ CTL_EMUL, EMUL_OSF1, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "kern",
+ SYSCTL_DESCR("OSF1 kernel emulation settings"),
+ NULL, 0, NULL, 0,
+ CTL_EMUL, EMUL_OSF1, EMUL_OSF1_KERN, CTL_EOL);
+
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_STRING, "ostype",
+ SYSCTL_DESCR("OSF1 operating system type"),
+ NULL, 0, osf1_sysname, sizeof(osf1_sysname),
+ CTL_EMUL, EMUL_OSF1, EMUL_OSF1_KERN,
+ EMUL_OSF1_KERN_OSTYPE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_STRING, "osrelease",
+ SYSCTL_DESCR("OSF1 operating system release"),
+ NULL, 0, osf1_release, sizeof(osf1_release),
+ CTL_EMUL, EMUL_OSF1, EMUL_OSF1_KERN,
+ EMUL_OSF1_KERN_OSRELEASE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_STRING, "osversion",
+ SYSCTL_DESCR("OSF1 operating system revision"),
+ NULL, 0, osf1_version, sizeof(osf1_version),
+ CTL_EMUL, EMUL_OSF1, EMUL_OSF1_KERN,
+ EMUL_OSF1_KERN_OSVERSION, CTL_EOL);
+}
Index: sys/sys/sysctl.h
===================================================================
RCS file: /cvsroot/src/sys/sys/sysctl.h,v
retrieving revision 1.153
diff -u -r1.153 sysctl.h
--- sys/sys/sysctl.h 17 Mar 2006 08:50:36 -0000 1.153
+++ sys/sys/sysctl.h 6 Apr 2006 13:14:27 -0000
@@ -900,8 +900,9 @@
#define EMUL_DARWIN 3
#define EMUL_MACH 4
#define EMUL_LINUX32 5
+#define EMUL_OSF1 6
-#define EMUL_MAXID 6
+#define EMUL_MAXID 7
#define CTL_EMUL_NAMES { \
{ 0, 0 }, \
{ "linux", CTLTYPE_NODE }, \
@@ -909,6 +910,7 @@
{ "darwin", CTLTYPE_NODE }, \
{ "mach", CTLTYPE_NODE }, \
{ "linux32", CTLTYPE_NODE }, \
+ { "osf1", CTLTYPE_NODE }, \
}
#ifdef _KERNEL
--envbJBWh7q8WU6mo--