]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/linux_version.c
import ceph quincy 17.2.4
[ceph.git] / ceph / src / common / linux_version.c
CommitLineData
7c673cae
FG
1#include "common/linux_version.h"
2
3#include <stdio.h>
4#include <string.h>
5#include <sys/utsname.h>
6
7int 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}