summaryrefslogtreecommitdiffstats
path: root/usr.bin/mkimg
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2015-06-11 15:18:54 +0000
committermarcel <marcel@FreeBSD.org>2015-06-11 15:18:54 +0000
commitd7cd5ce73af6485320dfb339743ee5a1b1d77f09 (patch)
treeee646f5285fe74d3a1f85b8b3abc0686b579b827 /usr.bin/mkimg
parent7577833480685b0e8e3569ee18ebc6fcc6292adb (diff)
downloadFreeBSD-src-d7cd5ce73af6485320dfb339743ee5a1b1d77f09.zip
FreeBSD-src-d7cd5ce73af6485320dfb339743ee5a1b1d77f09.tar.gz
Handle the case in which ncyls is 0.
While here, update copyright.
Diffstat (limited to 'usr.bin/mkimg')
-rw-r--r--usr.bin/mkimg/vhd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/mkimg/vhd.c b/usr.bin/mkimg/vhd.c
index 909872d..6860c16 100644
--- a/usr.bin/mkimg/vhd.c
+++ b/usr.bin/mkimg/vhd.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014 Marcel Moolenaar
+ * Copyright (c) 2014, 2015 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -120,17 +120,19 @@ vhd_geometry(uint64_t image_size, struct vhd_geom *geom)
lba_t imgsz;
long cth;
+ imgsz = image_size / VHD_SECTOR_SIZE;
+
/* Respect command line options if possible. */
if (nheads > 1 && nheads < 256 &&
nsecs > 1 && nsecs < 256 &&
ncyls < 65536) {
- geom->cylinders = ncyls;
+ geom->cylinders = (ncyls != 0) ? ncyls :
+ imgsz / (nheads * nsecs);
geom->heads = nheads;
geom->sectors = nsecs;
return;
}
- imgsz = image_size / VHD_SECTOR_SIZE;
if (imgsz > 65536 * 16 * 255)
imgsz = 65536 * 16 * 255;
if (imgsz >= 65535 * 16 * 63) {
OpenPOWER on IntegriCloud