svn commit: r365667 - stable/12/sys/geom/part

Eugene Grosbein eugen at FreeBSD.org
Sat Sep 12 18:40:40 UTC 2020


Author: eugen
Date: Sat Sep 12 18:40:39 2020
New Revision: 365667
URL: https://svnweb.freebsd.org/changeset/base/365667

Log:
  MFC r365477: geom_part: extend kern.geom.part.check_integrity to work on GPT
  
  In short, this change allows accessing partition and recovering secondary
  GPT in case it is unaccessible but primary table is fine.
  
  Reported by:	Alex Korchmar

Modified:
  stable/12/sys/geom/part/g_part.c
  stable/12/sys/geom/part/g_part_gpt.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/part/g_part.c
==============================================================================
--- stable/12/sys/geom/part/g_part.c	Sat Sep 12 18:23:27 2020	(r365666)
+++ stable/12/sys/geom/part/g_part.c	Sat Sep 12 18:40:39 2020	(r365667)
@@ -135,9 +135,9 @@ struct g_part_alias_list {
 SYSCTL_DECL(_kern_geom);
 SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0,
     "GEOM_PART stuff");
-static u_int check_integrity = 1;
+u_int geom_part_check_integrity = 1;
 SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity,
-    CTLFLAG_RWTUN, &check_integrity, 1,
+    CTLFLAG_RWTUN, &geom_part_check_integrity, 1,
     "Enable integrity checking");
 static u_int auto_resize = 1;
 SYSCTL_UINT(_kern_geom_part, OID_AUTO, auto_resize,
@@ -420,7 +420,7 @@ g_part_check_integrity(struct g_part_table *table, str
 	if (failed != 0) {
 		printf("GEOM_PART: integrity check failed (%s, %s)\n",
 		    pp->name, table->gpt_scheme->name);
-		if (check_integrity != 0)
+		if (geom_part_check_integrity != 0)
 			return (EINVAL);
 		table->gpt_corrupt = 1;
 	}

Modified: stable/12/sys/geom/part/g_part_gpt.c
==============================================================================
--- stable/12/sys/geom/part/g_part_gpt.c	Sat Sep 12 18:23:27 2020	(r365666)
+++ stable/12/sys/geom/part/g_part_gpt.c	Sat Sep 12 18:40:39 2020	(r365667)
@@ -64,6 +64,8 @@ SYSCTL_UINT(_kern_geom_part_gpt, OID_AUTO, allow_nesti
 CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
 CTASSERT(sizeof(struct gpt_ent) == 128);
 
+extern u_int geom_part_check_integrity;
+
 #define	EQUUID(a,b)	(memcmp(a, b, sizeof(struct uuid)) == 0)
 
 #define	MBRSIZE		512
@@ -460,8 +462,9 @@ gpt_read_hdr(struct g_part_gpt_table *table, struct g_
 	if (hdr->hdr_lba_self != table->lba[elt])
 		goto fail;
 	hdr->hdr_lba_alt = le64toh(buf->hdr_lba_alt);
-	if (hdr->hdr_lba_alt == hdr->hdr_lba_self ||
-	    hdr->hdr_lba_alt > last)
+	if (hdr->hdr_lba_alt == hdr->hdr_lba_self)
+		goto fail;
+	if (hdr->hdr_lba_alt > last && geom_part_check_integrity)
 		goto fail;
 
 	/* Check the managed area. */


More information about the svn-src-all mailing list