Date: Mon, 16 Jun 2003 12:42:48 +0200 From: Dag-Erling Smorgrav <des@ofug.org> To: emulation@freebsd.org Subject: uname enhancement Message-ID: <xzpbrwy1exj.fsf@flood.ping.uio.no>
index | next in thread | raw e-mail
[-- Attachment #1 --]
- the entire FreeBSD kernel version was being copied into
utsname.version. This string contains newline characters which
Linux apps do not expect, and is often too long to fit anyway.
- on i386, utsname.machine was always set to "i386". Linux normally
reports the precise CPU class it's running on (e.g. "i686" for
Pentium Pro, Pentium II, Celeron, Xeon, Athlon, Duron etc.). This
causes some applications (such as BEA WebLogic Server) to fail
because the developers never expected anyone to run their software
on an i386.
before:
des@meali ~/bea% /compat/linux/bin/uname -a
Linux meali.registrar.no 2.4.2 FreeBSD 5.1-CURRENT #2: Sun Jun 15 17:31:50 CEST 2003
des@me i386 unknown
after:
des@meali ~/bea% /compat/linux/bin/uname -a
Linux meali.registrar.no 2.4.2 FreeBSD 5.1-CURRENT #2: Sun Jun 15 17:31:50 CEST 2003 i686 unknown
DES
--
Dag-Erling Smorgrav - des@ofug.org
[-- Attachment #2 --]
Index: sys/compat/linux/linux_misc.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_misc.c,v
retrieving revision 1.144
diff -u -r1.144 linux_misc.c
--- sys/compat/linux/linux_misc.c 10 Jun 2003 21:27:39 -0000 1.144
+++ sys/compat/linux/linux_misc.c 16 Jun 2003 10:25:40 -0000
@@ -75,6 +75,10 @@
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_util.h>
+#ifdef __i386__
+#include <machine/cputypes.h>
+#endif
+
#ifdef __alpha__
#define BSD_TO_LINUX_SIGNAL(sig) (sig)
#else
@@ -693,6 +697,7 @@
struct l_new_utsname utsname;
char osname[LINUX_MAX_UTSNAME];
char osrelease[LINUX_MAX_UTSNAME];
+ char *p;
#ifdef DEBUG
if (ldebug(newuname))
@@ -707,7 +712,32 @@
getcredhostname(td->td_ucred, utsname.nodename, LINUX_MAX_UTSNAME);
strlcpy(utsname.release, osrelease, LINUX_MAX_UTSNAME);
strlcpy(utsname.version, version, LINUX_MAX_UTSNAME);
+ for (p = utsname.version; *p != '\0'; ++p)
+ if (*p == '\n') {
+ *p = '\0';
+ break;
+ }
+#ifdef __i386__
+ {
+ const char *class;
+ switch (cpu_class) {
+ case CPUCLASS_686:
+ class = "i686";
+ break;
+ case CPUCLASS_586:
+ class = "i586";
+ break;
+ case CPUCLASS_486:
+ class = "i486";
+ break;
+ default:
+ class = "i386";
+ }
+ strlcpy(utsname.machine, class, LINUX_MAX_UTSNAME);
+ }
+#else
strlcpy(utsname.machine, machine, LINUX_MAX_UTSNAME);
+#endif
strlcpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME);
return (copyout(&utsname, args->buf, sizeof(utsname)));
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpbrwy1exj.fsf>
