summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/stand/efiboot/diskprobe.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64/stand/efiboot/diskprobe.c')
-rw-r--r--sys/arch/amd64/stand/efiboot/diskprobe.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/arch/amd64/stand/efiboot/diskprobe.c b/sys/arch/amd64/stand/efiboot/diskprobe.c
index 48f089c296f..5522d10cdbd 100644
--- a/sys/arch/amd64/stand/efiboot/diskprobe.c
+++ b/sys/arch/amd64/stand/efiboot/diskprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diskprobe.c,v 1.2 2020/12/09 18:10:18 krw Exp $ */
+/* $OpenBSD: diskprobe.c,v 1.3 2024/06/04 20:31:35 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -282,9 +282,10 @@ bootdev_has_hibernate(void)
void
check_hibernate(struct diskinfo *dip)
{
+ uint8_t buf[DEV_BSIZE];
daddr_t sec;
int error;
- union hibernate_info hib;
+ union hibernate_info *hib = (union hibernate_info *)&buf;
/* read hibernate */
if (dip->disklabel.d_partitions[1].p_fstype != FS_SWAP ||
@@ -292,10 +293,10 @@ check_hibernate(struct diskinfo *dip)
return;
sec = DL_GETPOFFSET(&dip->disklabel.d_partitions[1]) +
- DL_GETPSIZE(&dip->disklabel.d_partitions[1]) -
- (sizeof(union hibernate_info) / DEV_BSIZE);
+ DL_GETPSIZE(&dip->disklabel.d_partitions[1]) - 1;
- error = dip->strategy(dip, F_READ, sec, sizeof hib, &hib, NULL);
- if (error == 0 && hib.magic == HIBERNATE_MAGIC)
+ error = dip->strategy(dip, F_READ, DL_SECTOBLK(&dip->disklabel, sec),
+ sizeof buf, &buf, NULL);
+ if (error == 0 && hib->magic == HIBERNATE_MAGIC)
dip->bios_info.flags |= BDI_HIBVALID; /* Hibernate present */
}