Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / linux_version.c
1 #include "common/linux_version.h"
2
3 #include <stdio.h>
4 #include <string.h>
5 #include <sys/utsname.h>
6
7 int get_linux_version(void)
8 {
9         struct utsname ubuf;
10         int a, b, c;
11         int n;
12
13         if (uname(&ubuf) || strcmp(ubuf.sysname, "Linux"))
14                 return 0;
15
16         n = sscanf(ubuf.release, "%d.%d.%d", &a, &b, &c);
17         switch (n) {
18         case 3:
19                 return KERNEL_VERSION(a, b, c);
20         case 2:
21                 return KERNEL_VERSION(a, b, 0);
22         default:
23                 return 0;
24         }
25 }