[Midnightbsd-cvs] src [11263] trunk/usr.bin/uname/uname.c: add flags
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Jul 3 19:53:17 EDT 2018
Revision: 11263
http://svnweb.midnightbsd.org/src/?rev=11263
Author: laffer1
Date: 2018-07-03 19:53:17 -0400 (Tue, 03 Jul 2018)
Log Message:
-----------
add flags
Modified Paths:
--------------
trunk/usr.bin/uname/Makefile
trunk/usr.bin/uname/uname.1
trunk/usr.bin/uname/uname.c
Property Changed:
----------------
trunk/usr.bin/uname/uname.1
Modified: trunk/usr.bin/uname/Makefile
===================================================================
--- trunk/usr.bin/uname/Makefile 2018-07-03 23:51:41 UTC (rev 11262)
+++ trunk/usr.bin/uname/Makefile 2018-07-03 23:53:17 UTC (rev 11263)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
# @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= uname
Modified: trunk/usr.bin/uname/uname.1
===================================================================
--- trunk/usr.bin/uname/uname.1 2018-07-03 23:51:41 UTC (rev 11262)
+++ trunk/usr.bin/uname/uname.1 2018-07-03 23:53:17 UTC (rev 11263)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)uname.1 8.3 (Berkeley) 4/8/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/uname/uname.1 258394 2013-11-20 17:46:23Z peter $
.\"
-.Dd January 26, 2010
+.Dd November 20, 2013
.Dt UNAME 1
.Os
.Sh NAME
@@ -36,7 +37,7 @@
.Nd display information about the system
.Sh SYNOPSIS
.Nm
-.Op Fl aimnoprsv
+.Op Fl aiKmnoprsUv
.Sh DESCRIPTION
The
.Nm
@@ -55,6 +56,10 @@
were specified.
.It Fl i
Write the kernel ident to standard output.
+.It Fl K
+Write the
+.Mx
+version of the kernel.
.It Fl m
Write the type of the current hardware platform to standard output.
.It Fl n
@@ -70,6 +75,10 @@
to standard output.
.It Fl s
Write the name of the operating system implementation to standard output.
+.It Fl U
+Write the
+.Mx
+version of the user environment.
.It Fl v
Write the version level of this release of the operating system
to standard output.
@@ -79,6 +88,14 @@
.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
+.Mx
+development and user visible changes.
.Sh ENVIRONMENT
An environment variable composed of the string
.Ev UNAME_
@@ -91,6 +108,8 @@
.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 +123,10 @@
The
.Nm
command appeared in PWB UNIX.
+.Pp
+The
+.Fl K
+and
+.Fl U
+extension flags appeared in
+.Mx 1.0 .
Property changes on: trunk/usr.bin/uname/uname.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/uname/uname.c
===================================================================
--- trunk/usr.bin/uname/uname.c 2018-07-03 23:51:41 UTC (rev 11262)
+++ trunk/usr.bin/uname/uname.c 2018-07-03 23:53:17 UTC (rev 11263)
@@ -54,6 +54,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include <osreldate.h>
+
#define MFLAG 0x01
#define NFLAG 0x02
#define PFLAG 0x04
@@ -61,23 +63,28 @@
#define SFLAG 0x10
#define VFLAG 0x20
#define IFLAG 0x40
+#define UFLAG 0x80
+#define KFLAG 0x100
typedef void (*get_t)(void);
-get_t get_ident, get_platform, get_hostname, get_arch, get_release, get_sysname, get_version;
+static get_t get_ident, get_platform, get_hostname, get_arch,
+ get_release, get_sysname, get_kernvers, get_uservers, get_version;
-void native_ident(void);
-void native_platform(void);
-void native_hostname(void);
-void native_arch(void);
-void native_release(void);
-void native_sysname(void);
-void native_version(void);
-void print_uname(u_int);
-void setup_get(void);
-void usage(void);
+static void native_ident(void);
+static void native_platform(void);
+static void native_hostname(void);
+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);
-char *ident, *platform, *hostname, *arch, *release, *sysname, *version;
-int space;
+static char *ident, *platform, *hostname, *arch, *release, *sysname, *version, *kernvers, *uservers;
+static int space;
int
main(int argc, char *argv[])
@@ -88,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);
@@ -96,6 +103,9 @@
case 'i':
flags |= IFLAG;
break;
+ case 'K':
+ flags |= KFLAG;
+ break;
case 'm':
flags |= MFLAG;
break;
@@ -112,6 +122,9 @@
case 'o':
flags |= SFLAG;
break;
+ case 'U':
+ flags |= UFLAG;
+ break;
case 'v':
flags |= VFLAG;
break;
@@ -142,7 +155,7 @@
} \
} while (0)
-void
+static void
setup_get(void)
{
CHECK_ENV("s", sysname);
@@ -152,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) \
@@ -165,7 +180,7 @@
printf("%s", var); \
}
-void
+static void
print_uname(u_int flags)
{
PRINT_FLAG(flags, SFLAG, sysname);
@@ -175,11 +190,13 @@
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");
}
#define NATIVE_SYSCTL2_GET(var,mib0,mib1) \
-void \
+static void \
native_##var(void) \
{ \
int mib[] = { (mib0), (mib1) }; \
@@ -193,7 +210,7 @@
err(1, "sysctl");
#define NATIVE_SYSCTLNAME_GET(var,name) \
-void \
+static void \
native_##var(void) \
{ \
size_t len; \
@@ -242,9 +259,27 @@
NATIVE_SYSCTLNAME_GET(ident, "kern.ident") {
} NATIVE_SET;
-void
+static void
+native_uservers(void)
+{
+ static char buf[128];
+
+ snprintf(buf, sizeof(buf), "%d", __MidnightBSD_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);
}
More information about the Midnightbsd-cvs
mailing list