Module Name: src
Committed By: mlelstv
Date: Tue Nov 22 00:25:52 UTC 2022
Modified Files:
src/sbin/gpt: gpt.c resizedisk.c
Log Message:
Big-Endian fixes.
To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/resizedisk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/gpt/gpt.c
diff -u src/sbin/gpt/gpt.c:1.83 src/sbin/gpt/gpt.c:1.84
--- src/sbin/gpt/gpt.c:1.83 Sun Nov 20 11:57:02 2022
+++ src/sbin/gpt/gpt.c Tue Nov 22 00:25:52 2022
@@ -35,7 +35,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: gpt.c,v 1.83 2022/11/20 11:57:02 mlelstv Exp $");
+__RCSID("$NetBSD: gpt.c,v 1.84 2022/11/22 00:25:52 mlelstv Exp $");
#endif
#include <sys/param.h>
@@ -578,6 +578,7 @@ gpt_open(const char *dev, int flags, int
if (found) {
struct map *map;
struct gpt_hdr *hdr;
+ uint64_t lba;
/*
* read secondary GPT from position stored in primary header
@@ -585,8 +586,9 @@ gpt_open(const char *dev, int flags, int
*/
map = map_find(gpt, MAP_TYPE_PRI_GPT_HDR);
hdr = map ? map->map_data : NULL;
- if (hdr && hdr->hdr_lba_alt > 0 && hdr->hdr_lba_alt < (uint64_t)devsz) {
- if (gpt_gpt(gpt, (off_t)hdr->hdr_lba_alt, found) == -1)
+ lba = le64toh(hdr->hdr_lba_alt);
+ if (hdr && lba > 0 && lba < (uint64_t)devsz) {
+ if (gpt_gpt(gpt, (off_t)lba, found) == -1)
goto close;
}
} else {
Index: src/sbin/gpt/resizedisk.c
diff -u src/sbin/gpt/resizedisk.c:1.19 src/sbin/gpt/resizedisk.c:1.20
--- src/sbin/gpt/resizedisk.c:1.19 Sun Nov 20 11:57:02 2022
+++ src/sbin/gpt/resizedisk.c Tue Nov 22 00:25:52 2022
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: resizedisk.c,v 1.19 2022/11/20 11:57:02 mlelstv Exp $");
+__RCSID("$NetBSD: resizedisk.c,v 1.20 2022/11/22 00:25:52 mlelstv Exp $");
#endif
#include <sys/bootblock.h>
@@ -194,7 +194,7 @@ resizedisk(gpt_t gpt, off_t sector, off_
}
hdr = gpt->gpt->map_data;
- hdr->hdr_lba_alt = (uint64_t)gpt->tpg->map_start;
+ hdr->hdr_lba_alt = htole64((uint64_t)gpt->tpg->map_start);
hdr->hdr_crc_self = 0;
hdr->hdr_lba_end = htole64((uint64_t)(gpt->lbt->map_start - 1));
hdr->hdr_crc_self =