Standards / Extensions | C or C++ | Dependencies |
---|---|---|
Language Environment | both | OS/390 V2R10 |
#define _POSIX_SOURCE
#include <sys/utsname.h>
int __osname(struct utsname *name);
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.
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.
Operating system | Sysname | Release | Version |
---|---|---|---|
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 |
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.
⁄*
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);
}
}
Sysname: z/OS
Nodename: SY1
Release: 01.00
Version: 02
Machine: 2097