OSDN Git Service

Linux kernel versions aren't always 3-tuples any more.
authorPeter Jones <pjones@redhat.com>
Fri, 10 Oct 2014 20:42:08 +0000 (16:42 -0400)
committerPeter Jones <pjones@redhat.com>
Fri, 10 Oct 2014 20:51:57 +0000 (16:51 -0400)
So we need to handle "3.10" as a version number correctly.

Signed-off-by: Peter Jones <pjones@redhat.com>
src/lib/gpt.c

index 8cb0e39..460b42a 100644 (file)
@@ -110,17 +110,21 @@ kernel_has_blkgetsize64(void)
 
         memset(&u, 0, sizeof(u));
         rc = uname(&u);
-        if (rc) return 0;
+        if (rc)
+               return 0;
 
         parsed = sscanf(u.release, "%d.%d.%d", &major, &minor, &patch);
-        if (parsed < 3) return 0;
-        if (major > 2) return 1;
-        if (major == 2 && minor > 5) return 1;
-        if (major == 2 && minor == 5 && patch >= 4) return 1;
-        if (major == 2 && minor == 4 && patch >= 18) return 1;
-        return 0;
-}
+       /* If the kernel is 2.4.15-2.4.18 and 2.5.0-2.5.3, i.e. the problem
+        * kernels, then this will get 3 answers.  If it doesn't, it isn't. */
+       if (parsed != 3)
+               return 1;
 
+       if (major == 2 && minor == 5 && patch < 4)
+               return 0;
+       if (major == 2 && minor == 4 && patch >= 15 && patch <= 18)
+               return 0;
+       return 1;
+}
 
 /************************************************************
  * _get_num_sectors
@@ -128,7 +132,7 @@ kernel_has_blkgetsize64(void)
  *  - filedes is an open file descriptor, suitable for reading
  * Modifies: nothing
  * Returns:
- *  Last LBA value on success 
+ *  Last LBA value on success
  *  0 on error
  *
  * Try getting BLKGETSIZE64 and BLKSSZGET first,
@@ -152,7 +156,7 @@ _get_num_sectors(int filedes)
         rc = ioctl(filedes, BLKGETSIZE, &sectors);
         if (rc)
                 return 0;
-        
+
        return sectors;
 }