summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-07-29 10:03:15 +0000
committerdes <des@FreeBSD.org>2003-07-29 10:03:15 +0000
commit8760f74f829c206d8169aab818520b692245bb33 (patch)
tree1c247011e7729baf41713936df99188666be22c6 /sys
parentc063c890f6fa45b6b3728c3da9fb6f90c8eed92f (diff)
downloadFreeBSD-src-8760f74f829c206d8169aab818520b692245bb33.zip
FreeBSD-src-8760f74f829c206d8169aab818520b692245bb33.tar.gz
Try to make 'uname -a' look more like it does on Linux:
- cut the version string at the newline, suppressing information about who built the kernel and in what directory. Most of this information was already lost to truncation. - on i386, return the precise CPU class (if known) rather than just "i386". Linux software which uses this information to select which binary to run often does not know what to make of "i386".
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/linux_misc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index a2b57bc..5797700 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -75,6 +75,10 @@ __FBSDID("$FreeBSD$");
#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
@@ -689,6 +693,7 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
struct l_new_utsname utsname;
char osname[LINUX_MAX_UTSNAME];
char osrelease[LINUX_MAX_UTSNAME];
+ char *p;
#ifdef DEBUG
if (ldebug(newuname))
@@ -703,7 +708,32 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args)
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)));
OpenPOWER on IntegriCloud