]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkfs.minix: check for misalignment
authorDavidlohr Bueso <dave@gnu.org>
Tue, 21 Jun 2011 03:10:13 +0000 (23:10 -0400)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Jun 2011 14:13:02 +0000 (16:13 +0200)
Produce a warning if the device is misaligned.

[kzak@redhat.com: - use it for block devices only]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkfs.minix.c

index 328e285a9785c1aa263f00ecaba66013aabec5d4..24b84db780b7e95db346feb48b57fb1c86384154 100644 (file)
@@ -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, &sectorsize) == -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);