From owner-svn-src-all@FreeBSD.ORG Tue Oct 15 20:57:40 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F0402307; Tue, 15 Oct 2013 20:57:40 +0000 (UTC) (envelope-from peter@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CDDA927EA; Tue, 15 Oct 2013 20:57:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9FKvevB095361; Tue, 15 Oct 2013 20:57:40 GMT (envelope-from peter@svn.freebsd.org) Received: (from peter@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9FKve8B095359; Tue, 15 Oct 2013 20:57:40 GMT (envelope-from peter@svn.freebsd.org) Message-Id: <201310152057.r9FKve8B095359@svn.freebsd.org> From: Peter Wemm Date: Tue, 15 Oct 2013 20:57:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256557 - head/usr.bin/uname X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Oct 2013 20:57:41 -0000 Author: peter Date: Tue Oct 15 20:57:40 2013 New Revision: 256557 URL: http://svnweb.freebsd.org/changeset/base/256557 Log: Add -K (__FreeBSD_version of kernel) and -U (__FreeBSD_version of userland). Things like Makefile.inc1 resort to parsing /usr/include/osreldate.h with awk because this isn't easily available by other means. The separation of user and kernel versions is important for jail/chroot environments. Modified: head/usr.bin/uname/uname.1 head/usr.bin/uname/uname.c Modified: head/usr.bin/uname/uname.1 ============================================================================== --- head/usr.bin/uname/uname.1 Tue Oct 15 20:21:27 2013 (r256556) +++ head/usr.bin/uname/uname.1 Tue Oct 15 20:57:40 2013 (r256557) @@ -36,7 +36,7 @@ .Nd display information about the system .Sh SYNOPSIS .Nm -.Op Fl aimnoprsv +.Op Fl aiKmnoprsUv .Sh DESCRIPTION The .Nm @@ -55,6 +55,10 @@ and were specified. .It Fl i Write the kernel ident to standard output. +.It Fl K +Write the +.Fx +version of the kernel. .It Fl m Write the type of the current hardware platform to standard output. .It Fl n @@ -70,6 +74,10 @@ Write the current release level of the o to standard output. .It Fl s Write the name of the operating system implementation to standard output. +.It Fl U +Write the +.Fx +version of the user environment. .It Fl v Write the version level of this release of the operating system to standard output. @@ -79,6 +87,14 @@ If the .Fl a flag is specified, or multiple flags are specified, all output is written on a single line, separated by spaces. +.Pp +The +.Fl K +and +.Fl U +flags are intended to be used for fine grain differentiation of incremental +.Fx +development and user visible changes. .Sh ENVIRONMENT An environment variable composed of the string .Ev UNAME_ @@ -91,6 +107,8 @@ of the environment variable. .Sh EXIT STATUS .Ex -std .Sh SEE ALSO +.Xr feature_present 3 , +.Xr getosreldate 3 , .Xr sysctl 3 , .Xr uname 3 , .Xr sysctl 8 @@ -104,3 +122,10 @@ specification. The .Nm command appeared in PWB UNIX. +.Pp +The +.Fl K +and +.Fl U +extension flags appeared in +.Fx 11.0 . Modified: head/usr.bin/uname/uname.c ============================================================================== --- head/usr.bin/uname/uname.c Tue Oct 15 20:21:27 2013 (r256556) +++ head/usr.bin/uname/uname.c Tue Oct 15 20:57:40 2013 (r256557) @@ -54,6 +54,8 @@ static const char sccsid[] = "@(#)uname. #include #include +#include + #define MFLAG 0x01 #define NFLAG 0x02 #define PFLAG 0x04 @@ -61,10 +63,12 @@ static const char sccsid[] = "@(#)uname. #define SFLAG 0x10 #define VFLAG 0x20 #define IFLAG 0x40 +#define UFLAG 0x80 +#define KFLAG 0x100 typedef void (*get_t)(void); static get_t get_ident, get_platform, get_hostname, get_arch, - get_release, get_sysname, get_version; + get_release, get_sysname, get_kernvers, get_uservers, get_version; static void native_ident(void); static void native_platform(void); @@ -73,11 +77,13 @@ static void native_arch(void); static void native_release(void); static void native_sysname(void); static void native_version(void); +static void native_kernvers(void); +static void native_uservers(void); static void print_uname(u_int); static void setup_get(void); static void usage(void); -static char *ident, *platform, *hostname, *arch, *release, *sysname, *version; +static char *ident, *platform, *hostname, *arch, *release, *sysname, *version, *kernvers, *uservers; static int space; int @@ -89,7 +95,7 @@ main(int argc, char *argv[]) setup_get(); flags = 0; - while ((ch = getopt(argc, argv, "aimnoprsv")) != -1) + while ((ch = getopt(argc, argv, "aiKmnoprsUv")) != -1) switch(ch) { case 'a': flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); @@ -97,6 +103,9 @@ main(int argc, char *argv[]) case 'i': flags |= IFLAG; break; + case 'K': + flags |= KFLAG; + break; case 'm': flags |= MFLAG; break; @@ -113,6 +122,9 @@ main(int argc, char *argv[]) case 'o': flags |= SFLAG; break; + case 'U': + flags |= UFLAG; + break; case 'v': flags |= VFLAG; break; @@ -153,6 +165,8 @@ setup_get(void) CHECK_ENV("m", platform); CHECK_ENV("p", arch); CHECK_ENV("i", ident); + CHECK_ENV("K", kernvers); + CHECK_ENV("U", uservers); } #define PRINT_FLAG(flags,flag,var) \ @@ -176,6 +190,8 @@ print_uname(u_int flags) PRINT_FLAG(flags, MFLAG, platform); PRINT_FLAG(flags, PFLAG, arch); PRINT_FLAG(flags, IFLAG, ident); + PRINT_FLAG(flags, KFLAG, kernvers); + PRINT_FLAG(flags, UFLAG, uservers); printf("\n"); } @@ -244,8 +260,26 @@ NATIVE_SYSCTLNAME_GET(ident, "kern.ident } NATIVE_SET; static void +native_uservers(void) +{ + static char buf[128]; + + snprintf(buf, sizeof(buf), "%d", __FreeBSD_version); + uservers = buf; +} + +static void +native_kernvers(void) +{ + static char buf[128]; + + snprintf(buf, sizeof(buf), "%d", getosreldate()); + kernvers = buf; +} + +static void usage(void) { - fprintf(stderr, "usage: uname [-aimnoprsv]\n"); + fprintf(stderr, "usage: uname [-aiKmnoprsUv]\n"); exit(1); }