routine for getting DU version (includes the letter)

From: Randy M. Hayman <haymanr_at_icefog.sois.alaska.edu>
Date: Mon, 14 Oct 96 08:29:37 -0800

Greetings -

This is a copy of my post to comp.unix.osf.osf1, for those of you who do
not follow that group:


After running across some interesting things under /usr/include I came
up with the following code to return a character string of the *real*
Digital UNIX version number (i.e. V3.2C, V3.2D-1, V4.0A, etc...) - as
opposed to the uname command which doesn't return the version letter, yet.
 
enjoy. No need to be root to compile this or execute this.

compile as follows (cc -o kernel_version -lpset -lmach kernel_version.c).


/* kernel_version.c kernel we're running and when built */
#include <mach.h>
#include <stdio.h>
#include <sys/utsname.h>

main()
{
long int status;
kernel_version_t version;
struct utsname uts_name;
char ut_host[SYS_NMLN];

    if(-1 == (status = uname(&uts_name))) {
        fprintf(stdout, "error %d getting uname structure\n", status);
        exit(1);
    }
    if(KERN_SUCCESS != (status = host_kernel_version(host_self(), version))) {
        fprintf(stderr, "Error %d returned from host_kernel_version\n", status);
        exit(1);
    }
    fprintf(stdout, "(%s) %s\n", &uts_name.nodename[0],version);
}



Randy M. Hayman
haymanr_at_icefog.alaska.edu
Received on Mon Oct 14 1996 - 19:41:18 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:47 NZDT