From 4f1384353e89132b9fc0b2a160fc3351aaa6973e Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Mon, 20 Jun 2011 23:10:13 -0400 Subject: [PATCH] mkfs.minix: check for misalignment Produce a warning if the device is misaligned. [kzak@redhat.com: - use it for block devices only] Signed-off-by: Davidlohr Bueso Signed-off-by: Karel Zak --- disk-utils/mkfs.minix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 328e285a97..24b84db780 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -653,6 +653,7 @@ int main(int argc, char ** argv) { DEV = open(device_name,O_RDWR | O_EXCL); else DEV = open(device_name,O_RDWR); + if (DEV<0) err(MKFS_ERROR, _("%s: open failed"), device_name); if (S_ISBLK(statbuf.st_mode)) { @@ -660,6 +661,10 @@ int main(int argc, char ** argv) { if (blkdev_get_sector_size(DEV, §orsize) == -1) sectorsize = DEFAULT_SECTOR_SIZE; /* kernel < 2.3.3 */ + + if (blkdev_is_misaligned(DEV)) + warnx(_("%s: device is misaligned"), device_name); + if (BLOCK_SIZE < sectorsize) errx(MKFS_ERROR, _("block size smaller than physical " "sector size of %s"), device_name); -- 2.47.2