diff options
author | 2018-12-13 14:06:10 +0000 | |
---|---|---|
committer | 2018-12-13 14:06:10 +0000 | |
commit | 1f3b82157bbd6cc6a4ce0e10482dc53f6343852c (patch) | |
tree | 57c3ce07a48cc5f476cfb5f0692e2052da3a0b8b | |
parent | we don't want to parse a filter command line (diff) | |
download | wireguard-openbsd-1f3b82157bbd6cc6a4ce0e10482dc53f6343852c.tar.xz wireguard-openbsd-1f3b82157bbd6cc6a4ce0e10482dc53f6343852c.zip |
Revert last. Breaks landisk snap building for currently unknown
reason.
Noticed by deraadt@
-rw-r--r-- | usr.sbin/installboot/bootstrap.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/usr.sbin/installboot/bootstrap.c b/usr.sbin/installboot/bootstrap.c index d55829d17aa..4a957cc26e5 100644 --- a/usr.sbin/installboot/bootstrap.c +++ b/usr.sbin/installboot/bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bootstrap.c,v 1.11 2018/11/25 17:34:37 krw Exp $ */ +/* $OpenBSD: bootstrap.c,v 1.12 2018/12/13 14:06:10 krw Exp $ */ /* * Copyright (c) 2013 Joel Sing <jsing@openbsd.org> @@ -78,16 +78,33 @@ bootstrap(int devfd, char *dev, char *bootfile) close(fd); /* - * Check that the bootstrap will not intrude into the OpenBSD area - * of the disk. + * Check that the bootstrap will fit - partitions must not overlap, + * or if they do, the partition type must be either FS_BOOT or + * FS_UNUSED. The 'c' partition will always overlap and is ignored. */ - if (bootsec > DL_GETBSTART(&dl)) - errx(1, "bootstrap (sectors 0 - %zu) overlaps OpenBSD " - " area (sectors %zu - %zu)", bootsec, - DL_GETBSTART(&dl), DL_GETBEND(&dl)); - else if (verbose) - fprintf(stderr, "bootstrap (sectors 0 - %zu) does not overlap " - "OpenBSD area.\n", bootsec); + if (verbose) + fprintf(stderr, "ensuring used partitions do not overlap " + "with bootstrap sectors 0-%zu\n", bootsec); + for (i = 0; i < dl.d_npartitions; i++) { + part = 'a' + i; + pp = &dl.d_partitions[i]; + if (i == RAW_PART) + continue; + if (DL_GETPSIZE(pp) == 0) + continue; + if ((u_int64_t)bootsec <= DL_GETPOFFSET(pp)) + continue; + switch (pp->p_fstype) { + case FS_BOOT: + break; + case FS_UNUSED: + warnx("bootstrap overlaps with unused partition %c", + part); + break; + default: + errx(1, "bootstrap overlaps with partition %c", part); + } + } /* * Make sure the bootstrap has left space for the disklabel. |