1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

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".
This commit is contained in:
Dag-Erling Smørgrav 2003-07-29 10:03:15 +00:00
parent b48997bff3
commit 7576b4b4c0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118149

View File

@ -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)));