From: Davidlohr Bueso Date: Tue, 21 Jun 2011 03:10:13 +0000 (-0400) Subject: mkfs.minix: check for misalignment X-Git-Tag: v2.20-rc1~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f1384353e89132b9fc0b2a160fc3351aaa6973e;p=thirdparty%2Futil-linux.git 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 --- 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);