From owner-freebsd-emulation@FreeBSD.ORG Mon Jun 16 03:42:52 2003 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1654D37B401 for ; Mon, 16 Jun 2003 03:42:52 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1569443F75 for ; Mon, 16 Jun 2003 03:42:51 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id AE74C530F; Mon, 16 Jun 2003 12:42:49 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: emulation@freebsd.org From: Dag-Erling Smorgrav Date: Mon, 16 Jun 2003 12:42:48 +0200 Message-ID: User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Subject: uname enhancement X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2003 10:42:52 -0000 --=-=-= The attached patch fixes two problems in linux_newuname(): - 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=linux-uname.diff 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 #include +#ifdef __i386__ +#include +#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))); --=-=-=--