mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-29 08:08:37 +00:00
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
This commit is contained in:
parent
7f63b888c7
commit
fb9a985516
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349469
@ -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 .
|
||||
|
@ -67,9 +67,10 @@ static const char sccsid[] = "@(#)uname.c 8.2 (Berkeley) 5/4/95";
|
||||
#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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user