Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Mar 2014 23:16:18 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r263849 - user/marcel/mkimg
Message-ID:  <201403272316.s2RNGI3F034141@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Thu Mar 27 23:16:18 2014
New Revision: 263849
URL: http://svnweb.freebsd.org/changeset/base/263849

Log:
  Properly fill in d_nsectors, d_ntracks, d_ncylinders & d_secpercyl.
  Round the image size to a multiple of the cyclinder size.

Modified:
  user/marcel/mkimg/bsd.c

Modified: user/marcel/mkimg/bsd.c
==============================================================================
--- user/marcel/mkimg/bsd.c	Thu Mar 27 23:15:07 2014	(r263848)
+++ user/marcel/mkimg/bsd.c	Thu Mar 27 23:16:18 2014	(r263849)
@@ -75,13 +75,16 @@ bsd_write(int fd, lba_t imgsz, void *boo
 	} else
 		memset(buf, 0, BBSIZE);
 
+	imgsz = ncyls * nheads * nsecs;
+	ftruncate(fd, imgsz * secsz);
+
 	d = (void *)(buf + LABELSECTOR * secsz + LABELOFFSET);
 	le32enc(&d->d_magic, DISKMAGIC);
 	le32enc(&d->d_secsize, secsz);
-	le32enc(&d->d_nsectors, 1);	/* XXX */
-	le32enc(&d->d_ntracks, 1);	/* XXX */
-	le32enc(&d->d_ncylinders, 0);	/* XXX */
-	le32enc(&d->d_secpercyl, 1);	/* XXX */
+	le32enc(&d->d_nsectors, nsecs);
+	le32enc(&d->d_ntracks, nheads);
+	le32enc(&d->d_ncylinders, ncyls);
+	le32enc(&d->d_secpercyl, nsecs * nheads);
 	le32enc(&d->d_secperunit, imgsz);
 	le16enc(&d->d_rpm, 3600);
 	le32enc(&d->d_magic2, DISKMAGIC);



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