summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-03-27 23:16:18 +0000
committermarcel <marcel@FreeBSD.org>2014-03-27 23:16:18 +0000
commitc4d8b579ba945fbd284fb702f8d09eeadf65dabf (patch)
tree33728af485005f9569d3387c701b98b0858da62f
parentda0f041a0e7ab782be9bfc36d2aa2634879b6f57 (diff)
downloadFreeBSD-src-c4d8b579ba945fbd284fb702f8d09eeadf65dabf.zip
FreeBSD-src-c4d8b579ba945fbd284fb702f8d09eeadf65dabf.tar.gz
Properly fill in d_nsectors, d_ntracks, d_ncylinders & d_secpercyl.
Round the image size to a multiple of the cyclinder size.
-rw-r--r--bsd.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/bsd.c b/bsd.c
index 7607b0f..7e28b9e 100644
--- a/bsd.c
+++ b/bsd.c
@@ -75,13 +75,16 @@ bsd_write(int fd, lba_t imgsz, void *bootcode)
} 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);
OpenPOWER on IntegriCloud