diff options
author | marcel <marcel@FreeBSD.org> | 2014-03-27 23:16:18 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2014-03-27 23:16:18 +0000 |
commit | c4d8b579ba945fbd284fb702f8d09eeadf65dabf (patch) | |
tree | 33728af485005f9569d3387c701b98b0858da62f | |
parent | da0f041a0e7ab782be9bfc36d2aa2634879b6f57 (diff) | |
download | FreeBSD-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.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); |