diff options
author | jmallett <jmallett@FreeBSD.org> | 2003-06-09 09:38:20 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2003-06-09 09:38:20 +0000 |
commit | f315e03eafe4decb20f007ba50f2c0bbd07209aa (patch) | |
tree | 63448f4636bc01d8e3847824509199f59c05b3b2 /usr.bin/uname/uname.c | |
parent | 0e96b35689d627ad5cfe6b881520841fae6da5c6 (diff) | |
download | FreeBSD-src-f315e03eafe4decb20f007ba50f2c0bbd07209aa.zip FreeBSD-src-f315e03eafe4decb20f007ba50f2c0bbd07209aa.tar.gz |
Make kernel identification (`ident' in the config(8) driver) available to
userland, and the kernel. In the kernel by way of the 'ident[]' variable
akin to all the other stuff generated by newvers.sh. In userland it is
available to sysctl consumers via KERN_IDENT or 'kern.ident'. It is exported
by uname(1) by the -i flag.
Reviewed by: hackers@
Diffstat (limited to 'usr.bin/uname/uname.c')
-rw-r--r-- | usr.bin/uname/uname.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c index a80d4f3..b650ebf 100644 --- a/usr.bin/uname/uname.c +++ b/usr.bin/uname/uname.c @@ -60,10 +60,12 @@ static const char sccsid[] = "@(#)uname.c 8.2 (Berkeley) 5/4/95"; #define RFLAG 0x08 #define SFLAG 0x10 #define VFLAG 0x20 +#define IFLAG 0x40 typedef void (*get_t)(void); -get_t get_platform, get_hostname, get_arch, get_release, get_sysname, get_version; +get_t get_ident, get_platform, get_hostname, get_arch, get_release, get_sysname, get_version; +void native_ident(void); void native_platform(void); void native_hostname(void); void native_arch(void); @@ -74,7 +76,7 @@ void print_uname(u_int); void setup_get(void); void usage(void); -char *platform, *hostname, *arch, *release, *sysname, *version; +char *ident, *platform, *hostname, *arch, *release, *sysname, *version; int space; int @@ -86,11 +88,14 @@ main(int argc, char *argv[]) setup_get(); flags = 0; - while ((ch = getopt(argc, argv, "amnprsv")) != -1) + while ((ch = getopt(argc, argv, "aimnprsv")) != -1) switch(ch) { case 'a': flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); break; + case 'i': + flags |= IFLAG; + break; case 'm': flags |= MFLAG; break; @@ -145,6 +150,7 @@ setup_get(void) CHECK_ENV("v", version); CHECK_ENV("m", platform); CHECK_ENV("p", arch); + CHECK_ENV("i", ident); } #define PRINT_FLAG(flags,flag,var) \ @@ -167,6 +173,7 @@ print_uname(u_int flags) PRINT_FLAG(flags, VFLAG, version); PRINT_FLAG(flags, MFLAG, platform); PRINT_FLAG(flags, PFLAG, arch); + PRINT_FLAG(flags, IFLAG, ident); printf("\n"); } @@ -218,9 +225,12 @@ NATIVE_SYSCTL2_GET(platform, CTL_HW, HW_MACHINE) { NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) { } NATIVE_SET; +NATIVE_SYSCTL2_GET(ident, CTL_KERN, KERN_IDENT) { +} NATIVE_SET; + void usage(void) { - fprintf(stderr, "usage: uname [-amnprsv]\n"); + fprintf(stderr, "usage: uname [-aimnprsv]\n"); exit(1); } |