summaryrefslogtreecommitdiffstats
path: root/usr.bin/mkimg
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-09-12 04:15:35 +0000
committermarcel <marcel@FreeBSD.org>2014-09-12 04:15:35 +0000
commit60c8581b5ed5cb6ae1697d8077ab06a896cd2302 (patch)
tree2f501cc03698187f2d3af185b5838065f87efcbc /usr.bin/mkimg
parent2cbd733015ac96c8967b8379dd59ef0f0001465d (diff)
downloadFreeBSD-src-60c8581b5ed5cb6ae1697d8077ab06a896cd2302.zip
FreeBSD-src-60c8581b5ed5cb6ae1697d8077ab06a896cd2302.tar.gz
Be compatible with boot code that starts right after the disk label in
the second sector by only clearing the amount of bytes needed for the disklabel in the second sector. Previously we were clearing exactly 1 sector worth of bytes and as such writing over boot code that may have been there. Since we do support more than 8 partitions, make sure to set all fields in d_partitions. For the first 8 partitions this is unneeded, but for partitioons 9 and up this compensates for the fact that we don't clear an entire sector anymore. Obviously, one cannot use more than 8 partitions when using boot code that starts right after the disk label. Relevant GRNs: 107879 - Employ unused bytes after the disklabel in the second sector. 189500 - Revert the part of change 107879 that employs the unused bytes after the disklabel in the 2nd sector for boot code. Obtained from: Juniper Networks, Inc. MFC after: 3 days
Diffstat (limited to 'usr.bin/mkimg')
-rw-r--r--usr.bin/mkimg/bsd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.bin/mkimg/bsd.c b/usr.bin/mkimg/bsd.c
index a3ed63d..c07ae14 100644
--- a/usr.bin/mkimg/bsd.c
+++ b/usr.bin/mkimg/bsd.c
@@ -76,7 +76,7 @@ bsd_write(lba_t imgsz, void *bootcode)
return (ENOMEM);
if (bootcode != NULL) {
memcpy(buf, bootcode, BBSIZE);
- memset(buf + secsz, 0, secsz);
+ memset(buf + secsz, 0, sizeof(struct disklabel));
} else
memset(buf, 0, BBSIZE);
@@ -110,7 +110,10 @@ bsd_write(lba_t imgsz, void *bootcode)
dp = &d->d_partitions[n];
le32enc(&dp->p_size, part->size);
le32enc(&dp->p_offset, part->block);
+ le32enc(&dp->p_fsize, 0);
dp->p_fstype = ALIAS_TYPE2INT(part->type);
+ dp->p_frag = 0;
+ le16enc(&dp->p_cpg, 0);
}
dp = &d->d_partitions[bsdparts];
OpenPOWER on IntegriCloud