2011-06-04 19:40:29 +02:00
|
|
|
/* Suite version information for procps-ng utilities
|
2002-02-01 22:47:29 +00:00
|
|
|
* Copyright (c) 1995 Martin Schulze <joey@infodrom.north.de>
|
|
|
|
* Ammended by cblake to only export the function symbol.
|
2002-12-15 00:30:17 +00:00
|
|
|
*
|
2003-02-09 07:27:16 +00:00
|
|
|
* Modified by Albert Cahalan, ????-2003
|
2002-12-15 00:30:17 +00:00
|
|
|
*
|
2002-02-01 22:47:29 +00:00
|
|
|
* Redistributable under the terms of the
|
|
|
|
* GNU Library General Public License; see COPYING
|
|
|
|
*/
|
2011-06-04 16:26:58 +02:00
|
|
|
|
2002-02-01 22:47:29 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-10-10 00:01:37 +00:00
|
|
|
#include "version.h"
|
2002-02-01 22:47:29 +00:00
|
|
|
|
2011-06-04 16:48:01 +02:00
|
|
|
const char procps_version[] = PACKAGE_NAME " version " PACKAGE_VERSION;
|
2002-02-01 22:47:29 +00:00
|
|
|
|
|
|
|
void display_version(void) {
|
|
|
|
fprintf(stdout, "%s\n", procps_version);
|
|
|
|
}
|
|
|
|
|
2011-06-04 19:40:29 +02:00
|
|
|
/* Linux kernel version information for procps-ng utilities
|
2002-02-01 22:47:29 +00:00
|
|
|
* Copyright (c) 1996 Charles Blake <cblake@bbn.com>
|
|
|
|
*/
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
|
|
|
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
|
|
|
|
|
2003-02-09 07:27:16 +00:00
|
|
|
int linux_version_code;
|
2002-02-01 22:47:29 +00:00
|
|
|
|
2011-01-19 12:50:26 +01:00
|
|
|
void init_Linux_version(void) {
|
2002-02-01 22:47:29 +00:00
|
|
|
static struct utsname uts;
|
|
|
|
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
2011-06-20 17:54:06 +02:00
|
|
|
int version_string_depth;
|
2002-02-01 22:47:29 +00:00
|
|
|
|
|
|
|
if (uname(&uts) == -1) /* failure implies impending death */
|
|
|
|
exit(1);
|
2011-06-20 17:54:06 +02:00
|
|
|
|
|
|
|
version_string_depth = sscanf(uts.release, "%d.%d.%d", &x, &y, &z);
|
|
|
|
|
|
|
|
if ((version_string_depth < 2) || /* Non-standard for all known kernels */
|
|
|
|
((version_string_depth < 3) && (x < 3))) /* Non-standard for 2.x.x kernels */
|
2002-02-01 22:47:29 +00:00
|
|
|
fprintf(stderr, /* *very* unlikely to happen by accident */
|
|
|
|
"Non-standard uts for running kernel:\n"
|
|
|
|
"release %s=%d.%d.%d gives version code %d\n",
|
|
|
|
uts.release, x, y, z, LINUX_VERSION(x,y,z));
|
|
|
|
linux_version_code = LINUX_VERSION(x, y, z);
|
|
|
|
}
|