2 * version.h -- get running kernel version
4 * Copyright (C) 2008 Oracle. All rights reserved.
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.
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.
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.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA
23 #ifndef _NFS_UTILS_MOUNT_VERSION_H
24 #define _NFS_UTILS_MOUNT_VERSION_H
29 #include <sys/utsname.h>
31 static inline unsigned int MAKE_VERSION(unsigned int p, unsigned int q,
34 return (65536 * p) + (256 * q) + r;
37 static inline unsigned int linux_version_code(void)
39 struct utsname my_utsname;
40 unsigned int p, q = 0, r = 0;
42 /* UINT_MAX as backward compatibility code should not be run */
43 if (uname(&my_utsname))
46 /* UINT_MAX as future versions might not start with an integer */
47 if (sscanf(my_utsname.release, "%u.%u.%u", &p, &q, &r) < 1)
50 return MAKE_VERSION(p, q, r);
53 #endif /* _NFS_UTILS_MOUNT_VERSION_H */