Date: Thu, 27 Jun 2019 20:34:51 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r349469 - head/usr.bin/uname Message-ID: <201906272034.x5RKYpCE045979@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Thu Jun 27 20:34:50 2019 New Revision: 349469 URL: https://svnweb.freebsd.org/changeset/base/349469 Log: Expose the kernel's build-ID through `uname -b` After r348611 the kernel's build-ID is available via sysctl. Add a -b flag to uname to report it. Submitted by: Ali Mashtizadeh <ali_mashtizadeh.com> Reviewed by: markj, imp Relnotes: Yes Event: Waterloo Hackathon 2019 Differential Revision: https://reviews.freebsd.org/D20511 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 Thu Jun 27 20:18:12 2019 (r349468) +++ head/usr.bin/uname/uname.1 Thu Jun 27 20:34:50 2019 (r349469) @@ -28,7 +28,7 @@ .\" @(#)uname.1 8.3 (Berkeley) 4/8/94 .\" $FreeBSD$ .\" -.Dd May 31, 2017 +.Dd June 27, 2019 .Dt UNAME 1 .Os .Sh NAME @@ -36,7 +36,7 @@ .Nd display information about the system .Sh SYNOPSIS .Nm -.Op Fl aiKmnoprsUv +.Op Fl abiKmnoprsUv .Sh DESCRIPTION The .Nm @@ -53,6 +53,8 @@ Behave as though the options and .Fl v were specified. +.It Fl b +Write the kernel's linker-generated build-id to standard output. .It Fl i Write the kernel ident to standard output. .It Fl K @@ -152,3 +154,7 @@ and .Fl U extension flags appeared in .Fx 10.0 . +The +.Fl b +extension flag appeared in +.Fx 13.0 . Modified: head/usr.bin/uname/uname.c ============================================================================== --- head/usr.bin/uname/uname.c Thu Jun 27 20:18:12 2019 (r349468) +++ head/usr.bin/uname/uname.c Thu Jun 27 20:34:50 2019 (r349469) @@ -67,9 +67,10 @@ static const char sccsid[] = "@(#)uname.c 8.2 (Berkele #define IFLAG 0x40 #define UFLAG 0x80 #define KFLAG 0x100 +#define BFLAG 0x200 typedef void (*get_t)(void); -static get_t get_ident, get_platform, get_hostname, get_arch, +static get_t get_buildid, get_ident, get_platform, get_hostname, get_arch, get_release, get_sysname, get_kernvers, get_uservers, get_version; static void native_ident(void); @@ -81,11 +82,13 @@ static void native_sysname(void); static void native_version(void); static void native_kernvers(void); static void native_uservers(void); +static void native_buildid(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, *kernvers, *uservers; +static char *buildid, *ident, *platform, *hostname, *arch, *release, *sysname, + *version, *kernvers, *uservers; static int space; int @@ -97,11 +100,14 @@ main(int argc, char *argv[]) setup_get(); flags = 0; - while ((ch = getopt(argc, argv, "aiKmnoprsUv")) != -1) + while ((ch = getopt(argc, argv, "abiKmnoprsUv")) != -1) switch(ch) { case 'a': flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); break; + case 'b': + flags |= BFLAG; + break; case 'i': flags |= IFLAG; break; @@ -169,6 +175,7 @@ setup_get(void) CHECK_ENV("i", ident); CHECK_ENV("K", kernvers); CHECK_ENV("U", uservers); + CHECK_ENV("b", buildid); } #define PRINT_FLAG(flags,flag,var) \ @@ -194,6 +201,7 @@ print_uname(u_int flags) PRINT_FLAG(flags, IFLAG, ident); PRINT_FLAG(flags, KFLAG, kernvers); PRINT_FLAG(flags, UFLAG, uservers); + PRINT_FLAG(flags, BFLAG, buildid); printf("\n"); } @@ -261,6 +269,9 @@ NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) { NATIVE_SYSCTLNAME_GET(ident, "kern.ident") { } NATIVE_SET; +NATIVE_SYSCTLNAME_GET(buildid, "kern.build_id") { +} NATIVE_SET; + static void native_uservers(void) { @@ -282,6 +293,6 @@ native_kernvers(void) static void usage(void) { - fprintf(stderr, "usage: uname [-aiKmnoprsUv]\n"); + fprintf(stderr, "usage: uname [-abiKmnoprsUv]\n"); exit(1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906272034.x5RKYpCE045979>