bigbiff bigbiff | e60683a | 2013-02-22 20:55:50 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <sys/utsname.h> |
| 3 | |
| 4 | #include "linux_version.h" |
| 5 | |
| 6 | int 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 | } |