From f5dbfe789e65cc619c38aa25f2d21aa89bbe2ad5 Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Fri, 6 Sep 2013 21:40:31 -0400 Subject: [PATCH] uname: normalize release and version Most systems provide the full version number in the 'release' field and the kernel version in 'version'. Minix used to split the full version number between release and version which caused problems for pkgsrc and other applications. This patch brings Minix's uname in line with other systems such as NetBSD. It also brings the getty banner in line with NetBSD. Old Minix uname: sysname->Minix nodename->10.0.2.15 release->3 version->2.1 machine->i686 New Minix uname: sysname->Minix nodename->10.0.2.15 release->3.2.1 version->Minix 3.2.1 (GENERIC) machine->i686 Change-Id: I966633dfdcf2f9485966bb0d0d042afc45bbeb7d --- commands/getty/getty.c | 2 +- commands/uname/uname.c | 22 +++++++++++++--------- include/minix/config.h | 6 ++++-- kernel/main.c | 4 ++-- servers/pm/misc.c | 6 +++--- sys/conf/osrelease.sh | 6 +++--- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/commands/getty/getty.c b/commands/getty/getty.c index 14356c6b3..9e35fb2b6 100644 --- a/commands/getty/getty.c +++ b/commands/getty/getty.c @@ -88,7 +88,7 @@ void do_getty(char *name, size_t len, char **args, const char *ttyname) int ch; struct utsname utsname; char **banner, *t; - static char *def_banner[] = { "%s Release %r Version %v (%t)\n\n%n login: ", 0 }; + static char *def_banner[] = { "%s/%p (%t)\n\n%n login: ", 0 }; /* Clean up tty name. */ if((t = strrchr(ttyname, '/'))) ttyname = t + 1; diff --git a/commands/uname/uname.c b/commands/uname/uname.c index 9ed933168..c80d15319 100644 --- a/commands/uname/uname.c +++ b/commands/uname/uname.c @@ -4,11 +4,11 @@ * function: * * system name Minix - * node name waddles - * release name 1.5 - * version 10 - * machine name i86 - * arch i86 (Minix specific) + * node name 10.0.2.15 + * release name 3.2.1 + * version Minix 3.2.1 (GENERIC) + * machine name i686 + * arch i386 (Minix specific) */ #include @@ -23,6 +23,7 @@ #define SYSNAME ((unsigned) 0x01) #define NODENAME ((unsigned) 0x02) #define RELEASE ((unsigned) 0x04) +#define VERSION ((unsigned) 0x08) #define U_MACHINE ((unsigned) 0x10) #define ARCH ((unsigned) 0x20) @@ -78,7 +79,7 @@ char **argv; case 'n': info |= NODENAME; break; case 'r': info |= RELEASE; break; case 's': info |= SYSNAME; break; - case 'v': info |= RELEASE; break; + case 'v': info |= VERSION; break; case 'p': info |= ARCH; break; default: usage(); } @@ -106,16 +107,19 @@ char **argv; if ((info & (SYSNAME|NODENAME)) != 0) print(STDOUT_FILENO, " ", (char *) NULL); print(STDOUT_FILENO, un.release, (char *) NULL); - print(STDOUT_FILENO, ".", (char *) NULL); + } + if ((info & VERSION) != 0) { + if ((info & (SYSNAME|NODENAME|RELEASE)) != 0) + print(STDOUT_FILENO, " ", (char *) NULL); print(STDOUT_FILENO, un.version, (char *) NULL); } if ((info & U_MACHINE) != 0) { - if ((info & (SYSNAME|NODENAME|RELEASE)) != 0) + if ((info & (SYSNAME|NODENAME|RELEASE|VERSION)) != 0) print(STDOUT_FILENO, " ", (char *) NULL); print(STDOUT_FILENO, un.machine, (char *) NULL); } if ((info & ARCH) != 0) { - if ((info & (SYSNAME|NODENAME|RELEASE|U_MACHINE)) != 0) + if ((info & (SYSNAME|NODENAME|RELEASE|VERSION|U_MACHINE)) != 0) print(STDOUT_FILENO, " ", (char *) NULL); print(STDOUT_FILENO, un.arch, (char *) NULL); } diff --git a/include/minix/config.h b/include/minix/config.h index 926c64df6..3b9eb1738 100644 --- a/include/minix/config.h +++ b/include/minix/config.h @@ -2,8 +2,10 @@ #define _CONFIG_H /* Minix release and version numbers. */ -#define OS_RELEASE "3" -#define OS_VERSION "3.0" +#define OS_NAME "Minix" +#define OS_RELEASE "3.3.0" +#define OS_CONFIG "GENERIC" +#define OS_VERSION OS_NAME " " OS_RELEASE " (" OS_CONFIG ")" /* This file sets configuration parameters for the MINIX kernel, FS, and PM. * It is divided up into two main sections. The first section contains diff --git a/kernel/main.c b/kernel/main.c index dd0886ad6..d8e3bdf6b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -325,12 +325,12 @@ void kmain(kinfo_t *local_cbi) static void announce(void) { /* Display the MINIX startup banner. */ - printf("\nMINIX %s.%s. " + printf("\nMINIX %s. " #ifdef _VCS_REVISION "(" _VCS_REVISION ")\n" #endif "Copyright 2012, Vrije Universiteit, Amsterdam, The Netherlands\n", - OS_RELEASE, OS_VERSION); + OS_RELEASE); printf("MINIX is open source software, see http://www.minix3.org\n"); } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 579024f6b..725e877ad 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -33,10 +33,10 @@ #include "kernel/proc.h" struct utsname uts_val = { - "Minix", /* system name */ + OS_NAME, /* system name */ "noname", /* node/network name */ - OS_RELEASE, /* O.S. release (e.g. 1.5) */ - OS_VERSION, /* O.S. version (e.g. 10) */ + OS_RELEASE, /* O.S. release (e.g. 3.3.0) */ + OS_VERSION, /* O.S. version (e.g. Minix 3.3.0 (GENERIC)) */ "xyzzy", /* machine (cpu) type (filled in later) */ #if defined(__i386__) "i386", /* architecture */ diff --git a/sys/conf/osrelease.sh b/sys/conf/osrelease.sh index 9e6bf9f92..02f4c9e75 100644 --- a/sys/conf/osrelease.sh +++ b/sys/conf/osrelease.sh @@ -36,9 +36,9 @@ path="$0" [ "${path#/*}" = "$path" ] && path="./$path" -release=`grep OS_RELEASE ${path%/*}/../../include/minix/config.h | awk '{ print $3} ' | tr -d '"'` -major=`grep OS_VERSION ${path%/*}/../../include/minix/config.h | awk '{ print $3 }' | tr -d '"' | awk -F. ' { print $1 }'` -minor=`grep OS_VERSION ${path%/*}/../../include/minix/config.h | awk '{ print $3 }' | tr -d '"' | awk -F. ' { print $2 }'` +release=`grep "define OS_RELEASE" ${path%/*}/../../include/minix/config.h | awk '{ print $3} ' | tr -d '"' | awk -F. ' { print $1 }'` +major=`grep "define OS_RELEASE" ${path%/*}/../../include/minix/config.h | awk '{ print $3 }' | tr -d '"' | awk -F. ' { print $2 }'` +minor=`grep "define OS_RELEASE" ${path%/*}/../../include/minix/config.h | awk '{ print $3 }' | tr -d '"' | awk -F. ' { print $3 }'` case "$option" in -- 2.44.0