From: Yoram Bar-Haim Date: Sun, 22 Sep 2013 13:06:33 +0000 (+0300) Subject: fix flaw when kernel version is 3.x X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=3a382320e8d0b52a250efd8907f8429497de2335;p=am-utils-6.2.git fix flaw when kernel version is 3.x --- diff --git a/conf/mount/mount_linux.c b/conf/mount/mount_linux.c index 01fc8154..7ba8b539 100644 --- a/conf/mount/mount_linux.c +++ b/conf/mount/mount_linux.c @@ -264,14 +264,20 @@ do_opts: int linux_version_code(void) { + char *token; + int shift = 16; struct utsname my_utsname; static int release = 0; - if ( 0 == release && 0 == uname(&my_utsname)) { - release = 65536 * atoi(strtok(my_utsname.release, ".")) - + 256 * atoi(strtok(NULL, ".")) - + atoi(strtok(NULL, ".")); + if ( release || uname(&my_utsname)) + return release; + + for (token = strtok(my_utsname.release, "."); token && (shift > -1); token = strtok(NULL, ".")) + { + release |= (atoi(token) << shift); + shift -= 8; } + return release; }