__osname() — Get true operating system name

Standards

Standards / Extensions C or C++ Dependencies
Language Environment both OS/390 V2R10

Format

#define _POSIX_SOURCE
#include <sys/utsname.h>

int __osname(struct utsname *name);

General description

The __osname() function retrieves information identifying the true operating system you are running on. The argument name points to a memory area where a structure describing the true operating system the process is running on can be stored.

The information about the true operating system is returned in a utsname structure, which has the following elements:
char *sysname;
The true name of the implementation of the operating system.
char *nodename;
The node name of this particular machine. The node name is set by the SYSNAME sysparm (specified at IPL), and usually differentiates machines running at a single location.
char *release;
The true current release level of the implementation.
char *version;
The true current version level of the release.
char *machine;
The name of the hardware type the system is running on.

Each of the utsname structure elements is a normal C string, terminated with a NULL character.

The values returned by the __osname() function are not intended to be used for comparison purposes in order to determine a level of functionality provided by the operating system. This is because the version and release values are not guaranteed to be equal to or greater than the previous implementation.

Table 1 lists the true operating system information returned by the __osname() function.

Table 1. Operating system information returned by the __osname() fuction
Operating system Sysname Release Version
Start of changez/OS® V2.2End of change Start of changez/OSEnd of change Start of change02.00End of change Start of change02End of change
z/OS V2.1 z/OS 01.00 02
z/OS V1.13 z/OS 13.00 01
z/OS V1.12 z/OS 12.00 01
z/OS V1.11 z/OS 11.00 01
z/OS V1.10 z/OS 10.00 01
z/OS V1.9 z/OS 09.00 01
z/OS V1.8 z/OS 08.00 01
z/OS V1.7 z/OS 07.00 01
z/OS V1.6 z/OS 06.00 01
z/OS V1.5 z/OS 05.00 01
z/OS V1.4 z/OS 04.00 01
z/OS V1.3 z/OS 03.00 01
z/OS V1.2 z/OS 02.00 01
z/OS V1.1 z/OS 01.00 01
OS/390® V2.10 OS/390 10.00 02

Returned value

If successful, the __osname() function returns a nonnegative value.

If unsuccessful, the __osname() function returns -1 and an errno might be set to indicate the reason for the failure.

Example

CELEBO02
/*                                                                   
   This example gets information about the system you are running on.
 */                                                                  
#define _POSIX_SOURCE                                                
#include <sys/utsname.h>                                             
#include <stdio.h>                                                   
main() {                                                             
  struct utsname uts;                                                
  if (__osname(&uts) < 0)                                            
    perror("__osname() error");                                      
  else {                                                             
    printf("Sysname:  %s\n", uts.sysname);                           
    printf("Nodename: %s\n", uts.nodename);                          
    printf("Release:  %s\n", uts.release);                           
    printf("Version:  %s\n", uts.version);                           
    printf("Machine:  %s\n", uts.machine);                           
  }                                                                  
}                                                                    
Output Start of change
Sysname:  z/OS
Nodename: SY1
Release:  02.00
Version:  02
Machine:  2097
End of change