blob: 2bcc2cc65b43a1697fb8044b0765c1310e7cd747 [file] [log] [blame]
bigbiff bigbiffe60683a2013-02-22 20:55:50 -05001#include <stdio.h>
2#include <sys/utsname.h>
3
4#include "linux_version.h"
5
6int get_linux_version (void)
7{
8 static int kver = -1;
9 struct utsname uts;
10 int major = 0;
11 int minor = 0;
12 int teeny = 0;
13 int n;
14
15 if (kver != -1)
16 return kver;
17 if (uname (&uts))
18 return kver = 0;
19
20 n = sscanf(uts.release, "%d.%d.%d", &major, &minor, &teeny);
21 if (n < 1 || n > 3)
22 return kver = 0;
23
24 return kver = KERNEL_VERSION(major, minor, teeny);
25}