This functions returns the status of the device's alignment. It will
be 0 when aligned, otherwise return the offset.
[kzak@redhat.com: - returns 0 if the ioctl failed]
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
/* get hardware sector size */
int blkdev_get_sector_size(int fd, int *sector_size);
+/* specifies whether or not the device is misaligned */
+int blkdev_is_misaligned(int fd);
+
#endif /* BLKDEV_H */
}
+/*
+ * Return the alignment status of a device
+ */
+int blkdev_is_misaligned(int fd)
+{
+ int aligned;
+
+ if (ioctl(fd, BLKALIGNOFF, &aligned) < 0)
+ return 0; /* probably kernel < 2.6.32 */
+ return aligned;
+}
+
#ifdef TEST_PROGRAM
#include <stdio.h>
#include <stdlib.h>