mirror of
https://github.com/openbsd/src.git
synced 2026-04-24 06:04:47 +00:00
Fix two circumstances where the code didn't understand that struct disklabel
doesn't fit inside a sector anymore. There are a limited number of cases like this showing up throughout the tree, and we may want a better mechanism to hand-fix them. This however still means we need to find them.. ok krw
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: bootstrap.c,v 1.14 2025/09/17 16:12:10 deraadt Exp $ */
|
||||
/* $OpenBSD: bootstrap.c,v 1.15 2025/11/19 15:05:04 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Joel Sing <jsing@openbsd.org>
|
||||
@@ -112,12 +112,12 @@ bootstrap(int devfd, char *dev, char *bootfile)
|
||||
*/
|
||||
lp = (struct disklabel *)(boot + (LABELSECTOR * DEV_BSIZE) +
|
||||
LABELOFFSET);
|
||||
for (i = 0, p = (char *)lp; i < (int)sizeof(*lp); i++)
|
||||
for (i = 0, p = (char *)lp; i < dl16sz; i++)
|
||||
if (p[i] != 0)
|
||||
errx(1, "bootstrap has data in disklabel area");
|
||||
|
||||
/* Patch the disklabel into the bootstrap code. */
|
||||
memcpy(lp, &dl, sizeof(dl));
|
||||
memcpy(lp, &dl, dl16sz);
|
||||
|
||||
/* Write the bootstrap out to the disk. */
|
||||
if (verbose)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: installboot.c,v 1.17 2025/02/19 21:30:46 kettenis Exp $ */
|
||||
/* $OpenBSD: installboot.c,v 1.18 2025/11/19 15:05:04 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org>
|
||||
@@ -16,11 +16,14 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <util.h>
|
||||
|
||||
@@ -36,6 +39,14 @@ char *root;
|
||||
char *stage1;
|
||||
char *stage2;
|
||||
|
||||
/*
|
||||
* XXX Only read the old smaller "skinny" label for now which
|
||||
* has 16 partitions. offsetof() is used to carve struct disklabel.
|
||||
* Later we'll add code to read and process the "fat" label with
|
||||
* 52 partitions.
|
||||
*/
|
||||
size_t dl16sz = offsetof(struct disklabel, d_partitions[MAXPARTITIONS16]);
|
||||
|
||||
static __dead void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: installboot.h,v 1.17 2025/02/19 21:30:46 kettenis Exp $ */
|
||||
/* $OpenBSD: installboot.h,v 1.18 2025/11/19 15:05:04 deraadt Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2012, 2013 Joel Sing <jsing@openbsd.org>
|
||||
*
|
||||
@@ -28,6 +28,8 @@ extern char *root;
|
||||
extern char *stage1;
|
||||
extern char *stage2;
|
||||
|
||||
extern size_t dl16sz;
|
||||
|
||||
#ifdef BOOTSTRAP
|
||||
void bootstrap(int, char *, char *);
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: landisk_installboot.c,v 1.13 2025/09/17 16:12:10 deraadt Exp $ */
|
||||
/* $OpenBSD: landisk_installboot.c,v 1.14 2025/11/19 15:05:04 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 Joel Sing <jsing@openbsd.org>
|
||||
@@ -208,12 +208,12 @@ md_bootstrap(int devfd, char *dev, char *bootfile)
|
||||
*/
|
||||
lp = (struct disklabel *)(boot + (LABELSECTOR * DEV_BSIZE) +
|
||||
LABELOFFSET);
|
||||
for (i = 0, p = (char *)lp; i < (int)sizeof(*lp); i++)
|
||||
for (i = 0, p = (char *)lp; i < dl16sz; i++)
|
||||
if (p[i] != 0)
|
||||
errx(1, "bootstrap has data in disklabel area");
|
||||
|
||||
/* Patch the disklabel into the bootstrap code. */
|
||||
memcpy(lp, &dl, sizeof(dl));
|
||||
memcpy(lp, &dl, dl16sz);
|
||||
|
||||
/* Write the bootstrap out to the disk. */
|
||||
bootpos *= dl.d_secsize;
|
||||
|
||||
Reference in New Issue
Block a user