git: edfbbfd541ab - main - gpart: Move MBR efimedia reporting to a separate routine

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 02 Nov 2021 23:09:41 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=edfbbfd541ab9f7ba13b246d86bd0c36757ec660

commit edfbbfd541ab9f7ba13b246d86bd0c36757ec660
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-11-02 23:08:48 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-11-02 23:09:17 +0000

    gpart: Move MBR efimedia reporting to a separate routine
    
    Move the efimedia reporting to g_part_mbr_efimedia and use that from
    g_part_mbr_dumpconf to report it.
    
    Sponsored by:           Netflix
    Reviewed by:            mav
    Differential Revision:  https://reviews.freebsd.org/D32781
---
 sys/geom/part/g_part_mbr.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c
index 750d417bba5d..d5d18e52456d 100644
--- a/sys/geom/part/g_part_mbr.c
+++ b/sys/geom/part/g_part_mbr.c
@@ -308,13 +308,24 @@ g_part_mbr_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
 	return (0);
 }
 
+static void
+g_part_mbr_efimedia(struct g_part_mbr_table *table, struct g_part_mbr_entry *entry,
+    struct sbuf *sb)
+{
+	uint32_t dsn;
+
+	dsn = le32dec(table->mbr + DOSDSNOFF);
+	sbuf_printf(sb, "HD(%d,MBR,%#08x,%#jx,%#jx)",
+	    entry->base.gpe_index, dsn, (intmax_t)entry->base.gpe_start,
+	    (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1));
+}
+
 static void
 g_part_mbr_dumpconf(struct g_part_table *basetable, struct g_part_entry *baseentry,
     struct sbuf *sb, const char *indent)
 {
 	struct g_part_mbr_entry *entry;
 	struct g_part_mbr_table *table;
-	uint32_t dsn;
 
 	table = (struct g_part_mbr_table *)basetable;
 	entry = (struct g_part_mbr_entry *)baseentry;
@@ -327,10 +338,8 @@ g_part_mbr_dumpconf(struct g_part_table *basetable, struct g_part_entry *baseent
 		    entry->ent.dp_typ);
 		if (entry->ent.dp_flag & 0x80)
 			sbuf_printf(sb, "%s<attrib>active</attrib>\n", indent);
-		dsn = le32dec(table->mbr + DOSDSNOFF);
-		sbuf_printf(sb, "%s<efimedia>HD(%d,MBR,%#08x,%#jx,%#jx)", indent,
-		    entry->base.gpe_index, dsn, (intmax_t)entry->base.gpe_start,
-		    (intmax_t)(entry->base.gpe_end - entry->base.gpe_start + 1));
+		sbuf_printf(sb, "%s<efimedia>", indent);
+		g_part_mbr_efimedia(table, entry, sb);
 		sbuf_cat(sb, "</efimedia>\n");
 	} else {
 		/* confxml: scheme information */