PROCPS_LINUX_VERSION(3)

NAME
procps_linux_version - provide current version of Linux as an integer

SYNOPSIS
#include <proc/procps.h>

int procps_linux_version(void);

Link with -lprocps.

DESCRIPTION
The function procps_linux_version() returns the current Linux version as an integer. On non-Linux systems that have an emulated proc filesystem this function returns the version of the Linux emulation instead. The Linux version consists of a triple of positive integers representing the major, minor and patch versions of the kernel.

The library provides 3 macros for separating out the components.

    LINUX_VERSION_MAJOR(ver)
        Extract the major component from the given version integer.

    LINUX_VERSION_MINOR(ver)
        Extract the minor component from the given version integer.

    LINUX_VERSION_PATCH(ver)
        Extract the patch component from the given version integer.

To encode a given Linux version, such as using it to compare against the current version, use the following macro:

LINUX_VERSION(major,minor,patch)

RETURN VALUE
The procps_linux_version() returns a positive integer encoding the Linux version if successful. Otherwise returns a negative integer to one of the values defined below.

-EIO
    The procps library was unable to read the osrelease file.

-ERANGE
    Unable to parse the osrelease file.

procps_linux_version() may also return any (negated) value that fopen() may set errno to.

FILES

/proc/sys/kernel/osrelease
    Contains the release version of the Linux kernel or proc filesystem.

VERSIONS
procps_linux_version() first appeared in libproc-2 version 0.0.

BUGS
Due to the way the three numbers are encoded into a single integer, procps_linux_version() and the associated macros assume 255 for the maximum value for the minor and patch level and 32767 (hex 0x7fff) for the maximum value for the major version. In other words, when Linux v 32768.0.0 comes out, this function will break.

SEE ALSO
fopen(3), proc(5).