Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Big-Endian fixes.



details:   https://anonhg.NetBSD.org/src/rev/8831436730f1
branches:  trunk
changeset: 372400:8831436730f1
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Nov 22 00:25:52 2022 +0000

description:
Big-Endian fixes.

diffstat:

 sbin/gpt/gpt.c        |  8 +++++---
 sbin/gpt/resizedisk.c |  4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diffs (53 lines):

diff -r 4a0beb4f6081 -r 8831436730f1 sbin/gpt/gpt.c
--- a/sbin/gpt/gpt.c    Mon Nov 21 23:51:10 2022 +0000
+++ b/sbin/gpt/gpt.c    Tue Nov 22 00:25:52 2022 +0000
@@ -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 @@
        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 @@
                 */
                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 {
diff -r 4a0beb4f6081 -r 8831436730f1 sbin/gpt/resizedisk.c
--- a/sbin/gpt/resizedisk.c     Mon Nov 21 23:51:10 2022 +0000
+++ b/sbin/gpt/resizedisk.c     Tue Nov 22 00:25:52 2022 +0000
@@ -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 @@
        }
 
        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 =



Home | Main Index | Thread Index | Old Index