From 8760f74f829c206d8169aab818520b692245bb33 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 29 Jul 2003 10:03:15 +0000 Subject: 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". --- sys/compat/linux/linux_misc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sys/compat/linux/linux_misc.c') 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 #include +#ifdef __i386__ +#include +#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))); -- cgit v1.1