fix flaw when kernel version is 3.x
authorYoram Bar-Haim <bhyoram@zahav.net.il>
Sun, 22 Sep 2013 13:06:33 +0000 (16:06 +0300)
committerYoram Bar-Haim <bhyoram@zahav.net.il>
Sun, 22 Sep 2013 13:06:33 +0000 (16:06 +0300)
conf/mount/mount_linux.c

index 01fc81540a7108cfdf397a9a17e805cfb45c4ed6..7ba8b5393fc8c1765a80fb00c02d0dd942987064 100644 (file)
@@ -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;
 }