From 397c775ce686865fe07a57e09aa3fe97115f5187 Mon Sep 17 00:00:00 2001 From: Matthias Koenig Date: Thu, 6 Nov 2008 15:43:46 +0100 Subject: [PATCH] mkfs.minix: fix size detection blkdev_get_size returns size in bytes, so BLOCKS has to be calculated accordingly. Use stat value for size if device is not a block device. Signed-off-by: Matthias Koenig --- disk-utils/mkfs.minix.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index a5e09926..bbb81149 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -653,9 +653,14 @@ main(int argc, char ** argv) { die(_("cannot determine sector size for %s")); if (BLOCK_SIZE < sectorsize) die(_("block size smaller than physical sector size of %s")); - if (!BLOCKS && blkdev_get_size(DEV, &BLOCKS) == -1) - die(_("cannot determine size of %s")); + if (!BLOCKS) { + if (blkdev_get_size(DEV, &BLOCKS) == -1) + die(_("cannot determine size of %s")); + BLOCKS /= BLOCK_SIZE; + } } else if (!S_ISBLK(statbuf.st_mode)) { + if (!BLOCKS) + BLOCKS = statbuf.st_size / BLOCK_SIZE; check=0; } else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) die(_("will not try to make filesystem on '%s'")); -- 2.39.5