]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: [blkdev.c] more robust blkdev_is_misaligned()
authorKarel Zak <kzak@redhat.com>
Mon, 27 Jun 2011 13:57:14 +0000 (15:57 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Jun 2011 13:57:45 +0000 (15:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/blkdev.c

index b6f9bfd328147814cae8be7d8a916bab4c71b669..d889b787f175610a8a26f62dda30072e96a6308e 100644 (file)
@@ -240,7 +240,11 @@ int blkdev_is_misaligned(int fd)
 
        if (ioctl(fd, BLKALIGNOFF, &aligned) < 0)
                return 0;                       /* probably kernel < 2.6.32 */
-       return aligned;
+       /*
+        * Note that kernel returns -1 as alignement offset if no compatible
+        * sizes and alignments exist for stacked devices
+        */
+       return aligned != 0 ? 1 : 0;
 #else
        return 0;
 #endif