summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2011-06-27 15:57:14 +0200
committerKarel Zak2011-06-27 15:57:45 +0200
commit6678c06f5d15814a982397977c7e9f14c219137f (patch)
treef6b84bf7d87f158b17a1846d2d5866960101fa0d /lib
parentlib: [blkdev.c] add blkdev_get_physector_size() (diff)
downloadkernel-qcow2-util-linux-6678c06f5d15814a982397977c7e9f14c219137f.tar.gz
kernel-qcow2-util-linux-6678c06f5d15814a982397977c7e9f14c219137f.tar.xz
kernel-qcow2-util-linux-6678c06f5d15814a982397977c7e9f14c219137f.zip
lib: [blkdev.c] more robust blkdev_is_misaligned()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/blkdev.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/blkdev.c b/lib/blkdev.c
index b6f9bfd32..d889b787f 100644
--- a/lib/blkdev.c
+++ b/lib/blkdev.c
@@ -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