Blob Blame History Raw
autofs-5.0.6 - fix kernel verion check of version components

From: Ian Kent <ikent@redhat.com>

Oops, not following the ball.

The kernel may have (or will have at times) a two digit version number.
Fix the version check function to allow for this.
---

 CHANGELOG        |    1 +
 include/mounts.h |   15 +--------------
 lib/mounts.c     |   29 +++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 14 deletions(-)


--- autofs-5.0.6.orig/CHANGELOG
+++ autofs-5.0.6/CHANGELOG
@@ -46,6 +46,7 @@
 - duplicate parent options for included maps.
 - update ->timeout() function to not return timeout.
 - move timeout to map_source (allow per direct map timeout).
+- fix kernel verion check of version components.
 
 28/06/2011 autofs-5.0.6
 -----------------------
--- autofs-5.0.6.orig/include/mounts.h
+++ autofs-5.0.6/include/mounts.h
@@ -75,26 +75,13 @@ struct mnt_list {
 	struct list_head ordered;
 };
 
-static inline unsigned int linux_version_code(void)
-{
-	struct utsname my_utsname;
-	unsigned int p, q, r;
-	char *save;
-
-	if (uname(&my_utsname))
-		return 0;
-
-	p = (unsigned int) atoi(strtok_r(my_utsname.release, ".", &save));
-	q = (unsigned int) atoi(strtok_r(NULL, ".", &save));
-	r = (unsigned int) atoi(strtok_r(NULL, ".", &save));
-	return KERNEL_VERSION(p, q, r);
-}
 
 struct nfs_mount_vers {
 	unsigned int major;
 	unsigned int minor;
 	unsigned int fix;
 };
+unsigned int linux_version_code(void);
 int check_nfs_mount_version(struct nfs_mount_vers *, struct nfs_mount_vers *);
 extern unsigned int nfs_mount_uses_string_options;
 
--- autofs-5.0.6.orig/lib/mounts.c
+++ autofs-5.0.6/lib/mounts.c
@@ -46,6 +46,35 @@ static const char mnt_name_template[]
 static struct kernel_mod_version kver = {0, 0};
 static const char kver_options_template[]  = "fd=%d,pgrp=%u,minproto=3,maxproto=5";
 
+unsigned int linux_version_code(void)
+{
+	struct utsname my_utsname;
+	unsigned int p, q, r;
+	char *tmp, *save;
+
+	if (uname(&my_utsname))
+		return 0;
+
+	p = q = r = 0;
+
+	tmp = strtok_r(my_utsname.release, ".", &save);
+	if (!tmp)
+		return 0;
+	p = (unsigned int ) atoi(tmp);
+
+	tmp = strtok_r(NULL, ".", &save);
+	if (!tmp)
+		return KERNEL_VERSION(p, 0, 0);
+	q = (unsigned int) atoi(tmp);
+
+	tmp = strtok_r(NULL, ".", &save);
+	if (!tmp)
+		return KERNEL_VERSION(p, q, 0);
+	r = (unsigned int) atoi(tmp);
+
+	return KERNEL_VERSION(p, q, r);
+}
+
 unsigned int query_kproto_ver(void)
 {
 	struct ioctl_ops *ops = get_ioctl_ops();