Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jun 2015 15:18:54 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r284270 - head/usr.bin/mkimg
Message-ID:  <201506111518.t5BFIstC023319@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Thu Jun 11 15:18:54 2015
New Revision: 284270
URL: https://svnweb.freebsd.org/changeset/base/284270

Log:
  Handle the case in which ncyls is 0.
  While here, update copyright.

Modified:
  head/usr.bin/mkimg/vhd.c

Modified: head/usr.bin/mkimg/vhd.c
==============================================================================
--- head/usr.bin/mkimg/vhd.c	Thu Jun 11 14:30:31 2015	(r284269)
+++ head/usr.bin/mkimg/vhd.c	Thu Jun 11 15:18:54 2015	(r284270)
@@ -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
 	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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506111518.t5BFIstC023319>