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@
This commit is contained in:
Juli Mallett 2003-06-09 09:38:20 +00:00
parent 1081253fa0
commit c4119c76f8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116085
4 changed files with 24 additions and 7 deletions

View File

@ -86,6 +86,7 @@ fi
touch version touch version
v=`cat version` u=${USER-root} d=`pwd` h=`hostname` t=`date` v=`cat version` u=${USER-root} d=`pwd` h=`hostname` t=`date`
i=`make -V KERN_IDENT`
cat << EOF > vers.c cat << EOF > vers.c
$COPYRIGHT $COPYRIGHT
char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' }; char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
@ -94,6 +95,7 @@ char version[] = "${VERSION} #${v}: ${t}\\n ${u}@${h}:${d}\\n";
char ostype[] = "${TYPE}"; char ostype[] = "${TYPE}";
char osrelease[] = "${RELEASE}"; char osrelease[] = "${RELEASE}";
int osreldate = ${RELDATE}; int osreldate = ${RELDATE};
char ident[] = "${i}";
EOF EOF
echo `expr ${v} + 1` > version echo `expr ${v} + 1` > version

View File

@ -354,7 +354,8 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define KERN_USRSTACK 33 /* int: address of USRSTACK */ #define KERN_USRSTACK 33 /* int: address of USRSTACK */
#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ #define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */
#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ #define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */
#define KERN_MAXID 36 /* number of valid kern ids */ #define KERN_IDENT 36 /* string: kernel ident */
#define KERN_MAXID 37 /* number of valid kern ids */
#define CTL_KERN_NAMES { \ #define CTL_KERN_NAMES { \
{ 0, 0 }, \ { 0, 0 }, \
@ -392,6 +393,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
{ "usrstack", CTLTYPE_INT }, \ { "usrstack", CTLTYPE_INT }, \
{ "logsigexit", CTLTYPE_INT }, \ { "logsigexit", CTLTYPE_INT }, \
{ "iov_max", CTLTYPE_INT }, \ { "iov_max", CTLTYPE_INT }, \
{ "ident", CTLTYPE_STRING }, \
} }
/* /*
@ -581,6 +583,7 @@ SYSCTL_DECL(_compat);
extern char machine[]; extern char machine[];
extern char osrelease[]; extern char osrelease[];
extern char ostype[]; extern char ostype[];
extern char ident[];
/* Dynamic oid handling */ /* Dynamic oid handling */
struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist,

View File

@ -32,7 +32,7 @@
.\" @(#)uname.1 8.3 (Berkeley) 4/8/94 .\" @(#)uname.1 8.3 (Berkeley) 4/8/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd September 18, 2002 .Dd April 02, 2003
.Dt UNAME 1 .Dt UNAME 1
.Os .Os
.Sh NAME .Sh NAME
@ -40,7 +40,7 @@
.Nd display information about the system .Nd display information about the system
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl amnprsv .Op Fl aimnprsv
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
@ -57,6 +57,8 @@ Behave as though the options
and and
.Fl v .Fl v
were specified. were specified.
.It Fl i
Write the kernel ident to standard output.
.It Fl m .It Fl m
Write the type of the current hardware platform to standard output. Write the type of the current hardware platform to standard output.
.It Fl n .It Fl n

View File

@ -60,10 +60,12 @@ static const char sccsid[] = "@(#)uname.c 8.2 (Berkeley) 5/4/95";
#define RFLAG 0x08 #define RFLAG 0x08
#define SFLAG 0x10 #define SFLAG 0x10
#define VFLAG 0x20 #define VFLAG 0x20
#define IFLAG 0x40
typedef void (*get_t)(void); 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_platform(void);
void native_hostname(void); void native_hostname(void);
void native_arch(void); void native_arch(void);
@ -74,7 +76,7 @@ void print_uname(u_int);
void setup_get(void); void setup_get(void);
void usage(void); void usage(void);
char *platform, *hostname, *arch, *release, *sysname, *version; char *ident, *platform, *hostname, *arch, *release, *sysname, *version;
int space; int space;
int int
@ -86,11 +88,14 @@ main(int argc, char *argv[])
setup_get(); setup_get();
flags = 0; flags = 0;
while ((ch = getopt(argc, argv, "amnprsv")) != -1) while ((ch = getopt(argc, argv, "aimnprsv")) != -1)
switch(ch) { switch(ch) {
case 'a': case 'a':
flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
break; break;
case 'i':
flags |= IFLAG;
break;
case 'm': case 'm':
flags |= MFLAG; flags |= MFLAG;
break; break;
@ -145,6 +150,7 @@ setup_get(void)
CHECK_ENV("v", version); CHECK_ENV("v", version);
CHECK_ENV("m", platform); CHECK_ENV("m", platform);
CHECK_ENV("p", arch); CHECK_ENV("p", arch);
CHECK_ENV("i", ident);
} }
#define PRINT_FLAG(flags,flag,var) \ #define PRINT_FLAG(flags,flag,var) \
@ -167,6 +173,7 @@ print_uname(u_int flags)
PRINT_FLAG(flags, VFLAG, version); PRINT_FLAG(flags, VFLAG, version);
PRINT_FLAG(flags, MFLAG, platform); PRINT_FLAG(flags, MFLAG, platform);
PRINT_FLAG(flags, PFLAG, arch); PRINT_FLAG(flags, PFLAG, arch);
PRINT_FLAG(flags, IFLAG, ident);
printf("\n"); printf("\n");
} }
@ -218,9 +225,12 @@ NATIVE_SYSCTL2_GET(platform, CTL_HW, HW_MACHINE) {
NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) { NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) {
} NATIVE_SET; } NATIVE_SET;
NATIVE_SYSCTL2_GET(ident, CTL_KERN, KERN_IDENT) {
} NATIVE_SET;
void void
usage(void) usage(void)
{ {
fprintf(stderr, "usage: uname [-amnprsv]\n"); fprintf(stderr, "usage: uname [-aimnprsv]\n");
exit(1); exit(1);
} }