Switch BUILD_ARCH in Makefile to use uname -p suggested by ru.

Switch strncpy to strlcpy suggested by gad and issue found by pjd.
Add to uname(3) man page describing:
	UNAME_s
	UNAME_r
	UNAME_v
	UNAME_m
Add to getosreldate(3) man page describing:
	OSVERSION

Submitted by:	ru, pjd/gad
Reviewed by:	ru (man pages)
This commit is contained in:
Doug Ambrisko 2005-12-03 05:11:07 +00:00
parent 8fcc657635
commit c26efd485e
4 changed files with 43 additions and 7 deletions

View File

@ -122,7 +122,7 @@ _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
.error CPUTYPE global should be set with ?=.
.endif
.if make(buildworld)
BUILD_ARCH!= uname -m
BUILD_ARCH!= uname -p
.if ${MACHINE_ARCH} != ${BUILD_ARCH}
.error To cross-build, set TARGET_ARCH.
.endif

View File

@ -74,7 +74,7 @@ __xuname(int namesize, void *namebuf)
}
name->sysname[sizeof(name->sysname) - 1] = '\0';
if ((p = getenv("UNAME_s")))
strncpy(name->sysname, p, sizeof(name->sysname));
strlcpy(name->sysname, p, sizeof(name->sysname));
mib[0] = CTL_KERN;
mib[1] = KERN_HOSTNAME;
@ -100,7 +100,7 @@ __xuname(int namesize, void *namebuf)
}
name->release[sizeof(name->release) - 1] = '\0';
if ((p = getenv("UNAME_r")))
strncpy(name->release, p, sizeof(name->release));
strlcpy(name->release, p, sizeof(name->release));
/* The version may have newlines in it, turn them into spaces. */
mib[0] = CTL_KERN;
@ -123,7 +123,7 @@ __xuname(int namesize, void *namebuf)
}
}
if ((p = getenv("UNAME_v")))
strncpy(name->version, p, sizeof(name->version));
strlcpy(name->version, p, sizeof(name->version));
mib[0] = CTL_HW;
mib[1] = HW_MACHINE;
@ -137,6 +137,6 @@ __xuname(int namesize, void *namebuf)
}
name->machine[sizeof(name->machine) - 1] = '\0';
if ((p = getenv("UNAME_m")))
strncpy(name->machine, p, sizeof(name->machine));
strlcpy(name->machine, p, sizeof(name->machine));
return (rval);
}

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd January 30, 2003
.Dd December 2, 2005
.Dt GETOSRELDATE 3
.Os
.Sh NAME
@ -55,6 +55,15 @@ returns the value requested;
otherwise the value \-1 is returned and the global variable
.Va errno
is set to indicate the error.
.Sh ENVIRONMENT
.Bl -tag -width ".Ev OSVERSION"
.It Ev OSVERSION
If the environment variable
.Ev OSVERSION
is set, it will override the
.Fn getosreldate
return value.
.El
.Sh EXAMPLES
An example can be found in
.Pa /usr/share/examples/FreeBSD_version .

View File

@ -32,7 +32,7 @@
.\" @(#)uname.3 8.1 (Berkeley) 1/4/94
.\" $FreeBSD$
.\"
.Dd January 4, 1994
.Dd December 2, 2005
.Dt UNAME 3
.Os
.Sh NAME
@ -72,6 +72,33 @@ Machine hardware platform.
.El
.Sh RETURN VALUES
.Rv -std uname
.Sh ENVIRONMENT
.Bl -tag -width ".Ev UNAME_s"
.It Ev UNAME_s
If the environment variable
.Ev UNAME_s
is set, it will override the
.Va sysname
member.
.It Ev UNAME_r
If the environment variable
.Ev UNAME_r
is set, it will override the
.Va release
member.
.It Ev UNAME_v
If the environment variable
.Ev UNAME_v
is set, it will override the
.Va version
member.
.It Ev UNAME_m
If the environment variable
.Ev UNAME_m
is set, it will override the
.Va machine
member.
.El
.Sh ERRORS
The
.Fn uname