diff options
author | Matthias Koenig | 2008-11-06 15:43:46 +0100 |
---|---|---|
committer | Karel Zak | 2008-11-13 23:56:32 +0100 |
commit | 943add28825b3e514e5e2390764af14851b33c64 (patch) | |
tree | 32b92b55a8b44b1ff3cb83247672dbceb310499a /disk-utils/mkfs.minix.c | |
parent | fdisk: add some missing includes (diff) | |
download | kernel-qcow2-util-linux-943add28825b3e514e5e2390764af14851b33c64.tar.gz kernel-qcow2-util-linux-943add28825b3e514e5e2390764af14851b33c64.tar.xz kernel-qcow2-util-linux-943add28825b3e514e5e2390764af14851b33c64.zip |
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 <mkoenig@suse.de>
Diffstat (limited to 'disk-utils/mkfs.minix.c')
-rw-r--r-- | disk-utils/mkfs.minix.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index f97df2743..f0c45c468 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -654,9 +654,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'")); |