2016-04-14 17:58:38 +05:30
|
|
|
.\" (C) Copyright 2016 Craig Small <csmall@enc.com.au>
|
|
|
|
.\"
|
2016-04-16 04:04:08 +05:30
|
|
|
.\" %%%LICENSE_START(LGPL_2.1+)
|
|
|
|
.\" This manual is free software; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU Lesser General Public
|
|
|
|
.\" License as published by the Free Software Foundation; either
|
|
|
|
.\" version 2.1 of the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
.\" Lesser General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU Lesser General Public
|
|
|
|
.\" License along with this library; if not, write to the Free Software
|
|
|
|
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
.\" %%%LICENSE_END
|
|
|
|
.\"
|
2016-05-01 12:44:48 +05:30
|
|
|
.TH PROCPS_LINUX_VERSION 3 2016-05-01 "libproc-2"
|
2016-04-14 17:58:38 +05:30
|
|
|
.\" Please adjust this date whenever revising the manpage.
|
|
|
|
.\"
|
|
|
|
.SH NAME
|
|
|
|
procps_linux_version \-
|
|
|
|
provide current version of Linux as an integer
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <proc/procps.h>
|
|
|
|
.sp
|
|
|
|
.B int procps_linux_version(void);
|
|
|
|
.sp
|
|
|
|
Link with \fI\-lprocps\fP.
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The function
|
|
|
|
.BR procps_linux_version ()
|
2016-04-16 04:04:08 +05:30
|
|
|
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
|
2016-07-07 10:30:00 +05:30
|
|
|
the major, minor and patch versions of the kernel.
|
2016-04-16 04:04:08 +05:30
|
|
|
.PP
|
2016-04-14 17:58:38 +05:30
|
|
|
The library provides 3 macros for separating out the components.
|
|
|
|
.RS 4
|
|
|
|
.TP 1.2i
|
|
|
|
.BR LINUX_VERSION_MAJOR (ver)
|
|
|
|
Extract the major component from the given version integer.
|
|
|
|
.TP
|
|
|
|
.BR LINUX_VERSION_MINOR (ver)
|
|
|
|
Extract the minor component from the given version integer.
|
|
|
|
.TP
|
|
|
|
.BR LINUX_VERSION_PATCH (ver)
|
|
|
|
Extract the patch component from the given version integer.
|
|
|
|
.RE
|
|
|
|
.PP
|
2016-07-07 10:30:00 +05:30
|
|
|
To encode a given Linux version, such as using it to compare against the current
|
2016-04-14 17:58:38 +05:30
|
|
|
version, use the following macro:
|
|
|
|
.TP
|
|
|
|
.BI LINUX_VERSION( major , minor , patch )
|
|
|
|
|
|
|
|
.SH RETURN VALUE
|
2016-04-16 04:04:08 +05:30
|
|
|
The
|
2016-04-14 17:58:38 +05:30
|
|
|
.BR procps_linux_version ()
|
2016-04-16 04:04:08 +05:30
|
|
|
returns a positive integer encoding the Linux version if successful. Otherwise
|
|
|
|
returns a negative integer to one of the values defined below.
|
2016-04-14 17:58:38 +05:30
|
|
|
.TP
|
|
|
|
.B -EIO
|
|
|
|
The procps library was unable to read the osrelease file.
|
|
|
|
.TP
|
|
|
|
.B -ERANGE
|
|
|
|
Unable to parse the osrelease file.
|
|
|
|
.PP
|
|
|
|
.BR procps_linux_version ()
|
2016-04-16 04:04:08 +05:30
|
|
|
may also return any (negated) value that \fBfopen\fR() may set errno to.
|
|
|
|
|
|
|
|
.SH FILES
|
|
|
|
.TP
|
|
|
|
.I /proc/sys/kernel/osrelease
|
|
|
|
Contains the release version of the Linux kernel or proc filesystem.
|
|
|
|
|
|
|
|
.SH VERSIONS
|
|
|
|
.B procps_linux_version()
|
|
|
|
first appeared in libproc-2 version 0.0.
|
2016-04-14 17:58:38 +05:30
|
|
|
|
2016-05-01 12:44:48 +05:30
|
|
|
.SH BUGS
|
|
|
|
Due to the way the three numbers are encoded into a single integer,
|
|
|
|
.BR 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.
|
|
|
|
.\" Maj/6yr - In 7452 we'll think of something
|
|
|
|
|
2016-04-14 17:58:38 +05:30
|
|
|
.SH SEE ALSO
|
|
|
|
.BR fopen (3),
|
|
|
|
.BR proc (5).
|