Fix systeminfo.
1. return length is the string length even if the string would not fit. 2. add SI_ISALIST 3. on 32 bit emulation, don't return sparc64 as the arch!
This commit is contained in:
parent
810714086b
commit
c0ee8a4184
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svr4_stat.c,v 1.52 2005/02/26 23:10:21 perry Exp $ */
|
||||
/* $NetBSD: svr4_stat.c,v 1.53 2005/07/28 03:50:52 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.52 2005/02/26 23:10:21 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.53 2005/07/28 03:50:52 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -619,6 +619,16 @@ svr4_sys_systeminfo(l, v, retval)
|
||||
str = machine_arch;
|
||||
break;
|
||||
|
||||
case SVR4_SI_ISALIST:
|
||||
#if defined(__sparc__)
|
||||
str = "sparcv9 sparcv9-fsmuld sparcv8 sparcv8-fsmuld sparcv7 sparc";
|
||||
#elif defined(__i386__)
|
||||
str = "i386";
|
||||
#else
|
||||
str = "unknown";
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SVR4_SI_HW_SERIAL:
|
||||
snprintf(buf, sizeof(buf), "%lu", hostid);
|
||||
str = buf;
|
||||
@ -633,10 +643,15 @@ svr4_sys_systeminfo(l, v, retval)
|
||||
break;
|
||||
|
||||
case SVR4_SI_PLATFORM:
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__)
|
||||
str = "i86pc";
|
||||
#elif __sparc__
|
||||
str = "SUNW,SPARCstation-10"; /* XXX */
|
||||
#elif defined(__sparc__)
|
||||
#elif defined(__sparc__)
|
||||
{
|
||||
extern char machine_model[];
|
||||
|
||||
str = machine_model;
|
||||
}
|
||||
#else
|
||||
str = "unknown";
|
||||
#endif
|
||||
@ -664,16 +679,19 @@ svr4_sys_systeminfo(l, v, retval)
|
||||
|
||||
if (str) {
|
||||
len = strlen(str) + 1;
|
||||
if (len > rlen)
|
||||
len = rlen;
|
||||
if (len < rlen)
|
||||
rlen = len;
|
||||
|
||||
if (SCARG(uap, buf)) {
|
||||
error = copyout(str, SCARG(uap, buf), len);
|
||||
error = copyout(str, SCARG(uap, buf), rlen);
|
||||
if (error)
|
||||
return error;
|
||||
/* make sure we are NULL terminated */
|
||||
buf[0] = '\0';
|
||||
error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
|
||||
if (rlen > 0) {
|
||||
/* make sure we are NULL terminated */
|
||||
buf[0] = '\0';
|
||||
error = copyout(buf,
|
||||
&(SCARG(uap, buf)[rlen - 1]), 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
error = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: svr4_32_stat.c,v 1.15 2005/02/26 23:10:21 perry Exp $ */
|
||||
/* $NetBSD: svr4_32_stat.c,v 1.16 2005/07/28 03:50:52 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_stat.c,v 1.15 2005/02/26 23:10:21 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: svr4_32_stat.c,v 1.16 2005/07/28 03:50:52 christos Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -633,11 +633,25 @@ svr4_32_sys_systeminfo(l, v, retval)
|
||||
break;
|
||||
|
||||
case SVR4_SI_MACHINE:
|
||||
str = "sun4u"; /* XXXX -- this only runs on sparcv9 */
|
||||
str = "sun4m"; /* Lie, pretend we are 4m */
|
||||
break;
|
||||
|
||||
case SVR4_SI_ARCHITECTURE:
|
||||
#if defined(__sparc__)
|
||||
str = "sparc";
|
||||
#else
|
||||
str = machine_arch;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SVR4_SI_ISALIST:
|
||||
#if defined(__sparc__)
|
||||
str = "sparcv8 sparcv8-fsmuld sparcv7 sparc";
|
||||
#elif defined(__i386__)
|
||||
str = "i386";
|
||||
#else
|
||||
str = "unknown";
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SVR4_SI_HW_SERIAL:
|
||||
@ -654,9 +668,9 @@ svr4_32_sys_systeminfo(l, v, retval)
|
||||
break;
|
||||
|
||||
case SVR4_SI_PLATFORM:
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__)
|
||||
str = "i86pc";
|
||||
#elif __sparc__
|
||||
#elif defined(__sparc__)
|
||||
{
|
||||
extern char machine_model[];
|
||||
|
||||
@ -693,17 +707,20 @@ svr4_32_sys_systeminfo(l, v, retval)
|
||||
|
||||
if (str) {
|
||||
len = strlen(str) + 1;
|
||||
if (len > rlen)
|
||||
len = rlen;
|
||||
if (len < rlen)
|
||||
rlen = len;
|
||||
|
||||
if (SCARG(uap, buf)) {
|
||||
error = copyout(str, (caddr_t)(u_long)SCARG(uap, buf), len);
|
||||
error = copyout(str, (caddr_t)(u_long)SCARG(uap, buf),
|
||||
rlen);
|
||||
if (error)
|
||||
return error;
|
||||
/* make sure we are NULL terminated */
|
||||
buf[0] = '\0';
|
||||
error = copyout(buf, &(((caddr_t)(u_long)
|
||||
SCARG(uap, buf))[len - 1]), 1);
|
||||
if (rlen > 0) {
|
||||
/* make sure we are NULL terminated */
|
||||
buf[0] = '\0';
|
||||
error = copyout(buf, &(((caddr_t)(u_long)
|
||||
SCARG(uap, buf))[rlen - 1]), 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
error = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user