svn commit: r263849 - user/marcel/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Thu Mar 27 23:16:19 UTC 2014


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);


More information about the svn-src-user mailing list