1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Only install a second copy of the bootloader if the EFI System Partition

is at least 1MB.  This should prevent us from filling up the tiny ESPs
that we used to create a few releases ago.

ok deraadt@
This commit is contained in:
kettenis 2024-11-08 10:43:07 +00:00
parent ea7e0400ef
commit db15c72a19
2 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: efi_installboot.c,v 1.11 2024/10/30 16:22:33 kettenis Exp $ */
/* $OpenBSD: efi_installboot.c,v 1.12 2024/11/08 10:43:07 kettenis Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@ -193,6 +193,7 @@ write_filesystem(struct disklabel *dl, char part)
{
static const char *fsckfmt = "/sbin/fsck -t msdos %s >/dev/null";
struct msdosfs_args args;
struct statfs sf;
char cmd[60];
char dst[PATH_MAX];
char *src;
@ -309,6 +310,12 @@ write_filesystem(struct disklabel *dl, char part)
goto umount;
}
/* Skip installing a 2nd copy if we have a small filesystem. */
if (statfs(dst, &sf) || sf.f_blocks < 2048) {
rslt = 0;
goto firmware;
}
/* Create "/efi/openbsd" directory in <duid>.<part>. */
dst[mntlen] = '\0';
if (strlcat(dst, "/efi/openbsd", sizeof(dst)) >= sizeof(dst)) {
@ -343,6 +350,7 @@ write_filesystem(struct disklabel *dl, char part)
goto umount;
}
firmware:
dst[mntlen] = '\0';
rslt = write_firmware(root, dst);
if (rslt == -1)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: i386_installboot.c,v 1.47 2024/10/30 16:22:33 kettenis Exp $ */
/* $OpenBSD: i386_installboot.c,v 1.48 2024/11/08 10:43:07 kettenis Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@ -290,6 +290,9 @@ write_filesystem(struct disklabel *dl, char part)
{
static const char *fsckfmt = "/sbin/fsck -t msdos %s >/dev/null";
struct msdosfs_args args;
#ifdef __amd64__
struct statfs sf;
#endif
char cmd[60];
char dst[PATH_MAX];
char *src;
@ -416,6 +419,12 @@ write_filesystem(struct disklabel *dl, char part)
}
#ifdef __amd64__
/* Skip installing a 2nd copy if we have a small filesystem. */
if (statfs(dst, &sf) || sf.f_blocks < 2048) {
rslt = 0;
goto umount;
}
/* Create "/efi/openbsd" directory in <duid>.<part>. */
dst[mntlen] = '\0';
if (strlcat(dst, "/efi/openbsd", sizeof(dst)) >= sizeof(dst)) {