]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/mount/version.h
46552a1775be5682b602a85e30f3d25823d118dd
[nfs-utils.git] / utils / mount / version.h
1 /*
2  * version.h -- get running kernel version
3  *
4  * Copyright (C) 2008 Oracle.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA.
20  *
21  */
22
23 #ifndef _NFS_UTILS_MOUNT_VERSION_H
24 #define _NFS_UTILS_MOUNT_VERSION_H
25
26 #include <stdlib.h>
27 #include <string.h>
28
29 #include <sys/utsname.h>
30
31 static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q,
32                                         unsigned int r)
33 {
34         return (65536 * p) + (256 * q) + r;
35 }
36
37 static inline unsigned int linux_version_code(void)
38 {
39         struct utsname my_utsname;
40         unsigned int p, q, r;
41
42         if (uname(&my_utsname))
43                 return 0;
44
45         p = atoi(strtok(my_utsname.release, "."));
46         q = atoi(strtok(NULL, "."));
47         r = atoi(strtok(NULL, "."));
48         return MAKE_VERSION(p, q, r);
49 }
50
51 #endif  /* _NFS_UTILS_MOUNT_VERSION_H */