Note: I'm not set on the flag names. I figured these would be least likely to collide, but I haven't found -k or -u used anywhere else with a trivial search of linux systems. I'm sure there are some somewhere though. Here's how it looks: peter@daintree[ 2:23PM]~-1019> uname -K 1000055 peter@daintree[ 2:23PM]~-1020> uname -U 1000054 ie: I've got an out of sync userland and kernel on this machine. Compile, library, includes etc is at 1000054 and the kernel is later. Index: uname.1 =================================================================== --- uname.1 (revision 256232) +++ uname.1 (working copy) @@ -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 @@ 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 @@ 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. @@ -91,6 +99,7 @@ .Sh EXIT STATUS .Ex -std .Sh SEE ALSO +.Xr getosreldate 3 , .Xr sysctl 3 , .Xr uname 3 , .Xr sysctl 8 @@ -104,3 +113,10 @@ The .Nm command appeared in PWB UNIX. +.Pp +The +.Fl K +and +.Fl U +extension flags appeared in +.Fx 10.0 . Index: uname.c =================================================================== --- uname.c (revision 256232) +++ uname.c (working copy) @@ -54,6 +54,8 @@ #include #include +#include + #define MFLAG 0x01 #define NFLAG 0x02 #define PFLAG 0x04 @@ -61,10 +63,12 @@ #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_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 @@ 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); @@ -116,6 +122,12 @@ case 'v': flags |= VFLAG; break; + case 'K': + flags |= KFLAG; + break; + case 'U': + flags |= UFLAG; + break; case '?': default: usage(); @@ -153,6 +165,8 @@ 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_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"); } @@ -243,9 +259,24 @@ NATIVE_SYSCTLNAME_GET(ident, "kern.ident") { } NATIVE_SET; +static void native_uservers(void) +{ + static char buf[1024]; + + snprintf(buf, sizeof(buf), "%d", __FreeBSD_version); + uservers = buf; +} +static void native_kernvers(void) +{ + static char buf[1024]; + + 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); }