Subject: lib/254: uname(1) output breaks scripts, is unreadable
To: None <gnats-admin>
From: Thorsten Lockert <tholo@SigmaSoft.COM>
List: netbsd-bugs
Date: 05/20/1994 06:35:04
>Number:         254
>Category:       lib
>Synopsis:       The uname(2) emulation used by uname(1) could use improvement
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 20 06:35:03 1994
>Originator:     Thorsten Lockert
>Organization:
Thorsten Lockert  | postmaster@bbb.no   |
Postbox 435       | hostmaster@bbb.no   |  Universe, n.:
N-5001 Bergen     | tholo@bbb.no        |          The problem.
Norway            | tholo@sigmasoft.com |
>Release:        
>Environment:
	
System: NetBSD gandalf.bbb.no NetBSD 0.9B NetBSD 0.9B (GANDALF) #3: Wed May 18 20:04:22 MET DST 1994 tholo@gandalf.bbb.no:/usr/src/sys/arch/i386/compile/GANDALF i386


>Description:
	It would be better if the uname(2) emulation (now uname(3)) would
	return fields like "NetBSD" "node.domain", "0.9B", "199103" and "i386".
	That is, use the sysctl fields "kern.ostype", "kern.hostname",
	"kern.osrelease", "kern.osrevision" and "hw.machine" fields, and
	remove the "NetBSD " part from the "kern.osrelease" field as generated
	by /sys/conf/newvers.sh.  This would again make uname(1) usable by
	configuration scripts. If you want uname(1) to be able to give the full
	config version like above, would it not be better to add that as a new
	option to uname(1) or just use sysctl(1) to get at it?

	At the very least, the "version" field should not re-specify "NetBSD ",
	but only give the version, both for the uname(2) emulation and as a
	return on "sysctl kern.osrelease".
>How-To-Repeat:
	Run "uname -a"
>Fix:
--- src/sys/conf/newvers.sh.orig	Fri May 20 10:07:12 1994
+++ src/sys/conf/newvers.sh	Fri May 20 10:07:25 1994
@@ -44,7 +44,7 @@
 id=`basename ${d}`
 
 ost="NetBSD"
-osr="${ost} 0.9B"
+osr="0.9B"
 
 echo "char ostype[] = \"${ost}\";" > vers.c
 echo "char osrelease[] = \"${osr}\";" >> vers.c
--- src/lib/libc/gen/uname.c.orig	Fri May 20 10:07:44 1994
+++ src/lib/libc/gen/uname.c	Fri May 20 10:08:25 1994
@@ -69,18 +69,10 @@
 
 	/* The version may have newlines in it, turn them into spaces. */
 	mib[0] = CTL_KERN;
-	mib[1] = KERN_VERSION;
+	mib[1] = KERN_OSREVISION;
 	len = sizeof(name->version);
 	if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1)
 		rval = -1;
-	else
-		for (p = name->version; len--; ++p)
-			if (*p == '\n' || *p == '\t')
-				if (len > 1)
-					*p = ' ';
-				else
-					*p = '\0';
-
 	mib[0] = CTL_HW;
 	mib[1] = HW_MACHINE;
 	len = sizeof(name->machine);
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------