autofs-5.0.6 - fix kernel verion check of version components From: Ian Kent 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(-) diff --git a/CHANGELOG b/CHANGELOG index f3c1bba..9589139 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,6 +48,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 ----------------------- diff --git a/include/mounts.h b/include/mounts.h index 7c10f12..1efce64 100644 --- a/include/mounts.h +++ b/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; diff --git a/lib/mounts.c b/lib/mounts.c index cbf2e5e..ad78883 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -46,6 +46,35 @@ static const char mnt_name_template[] = "automount(pid%u)"; 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();