diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-07-29 10:03:15 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-07-29 10:03:15 +0000 |
commit | 7576b4b4c050db1512d39cc89a7524d8bc38454e (patch) | |
tree | 1c247011e7729baf41713936df99188666be22c6 | |
parent | b48997bff30b195020b6445187ef7efec5769f8f (diff) | |
download | src-7576b4b4c050db1512d39cc89a7524d8bc38454e.tar.gz src-7576b4b4c050db1512d39cc89a7524d8bc38454e.zip |
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".
Notes
Notes:
svn path=/head/; revision=118149
-rw-r--r-- | sys/compat/linux/linux_misc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index a2b57bc5deff..5797700b495c 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))); |