Module Name:    src
Committed By:   martin
Date:           Fri Dec 13 22:12:41 UTC 2019

Modified Files:
        src/usr.sbin/sysinst: bsddisklabel.c disklabel.c gpt.c label.c mbr.c
            partitions.c partitions.h partman.c

Log Message:
When finding (paritioning scheme native) partition types for file systems
from our install description, pass the partition type (not only the file
system type). Sometimes (e.g. EFI boot partition on GPT) the filesystem
type (MSDOS) is not a unique selector.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/sysinst/bsddisklabel.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sysinst/disklabel.c \
    src/usr.sbin/sysinst/mbr.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/sysinst/gpt.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/sysinst/partitions.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/partitions.h
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/sysinst/partman.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/bsddisklabel.c
diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.32 src/usr.sbin/sysinst/bsddisklabel.c:1.33
--- src/usr.sbin/sysinst/bsddisklabel.c:1.32	Sun Dec  8 15:09:33 2019
+++ src/usr.sbin/sysinst/bsddisklabel.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: bsddisklabel.c,v 1.32 2019/12/08 15:09:33 martin Exp $	*/
+/*	$NetBSD: bsddisklabel.c,v 1.33 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1320,7 +1320,7 @@ apply_settings_to_partitions(struct pm_d
 			infos[i].size = min(want->size, space.size);
 			infos[i].nat_type =
 			    ps->pscheme->get_fs_part_type(
-			        want->fs_type, want->fs_version);
+			        want->type, want->fs_type, want->fs_version);
 			infos[i].last_mounted = want->mount;
 			infos[i].fs_type = want->fs_type;
 			infos[i].fs_sub_type = want->fs_version;
@@ -1400,7 +1400,7 @@ apply_settings_to_partitions(struct pm_d
 			infos[i].size = min(want->size, space.size);
 			infos[i].nat_type =
 			    wanted->parts->pscheme->get_fs_part_type(
-			    want->fs_type, want->fs_version);
+			    want->type, want->fs_type, want->fs_version);
 			infos[i].last_mounted = want->mount;
 			infos[i].fs_type = want->fs_type;
 			infos[i].fs_sub_type = want->fs_version;
@@ -1444,7 +1444,7 @@ apply_settings_to_partitions(struct pm_d
 		infos[i].start = want->cur_start;
 		infos[i].size = want->size;
 		infos[i].nat_type = wanted->parts->pscheme->get_fs_part_type(
-		    want->fs_type, want->fs_version);
+		    want->type, want->fs_type, want->fs_version);
 		infos[i].last_mounted = want->mount;
 		infos[i].fs_type = want->fs_type;
 		infos[i].fs_sub_type = want->fs_version;

Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.22 src/usr.sbin/sysinst/disklabel.c:1.23
--- src/usr.sbin/sysinst/disklabel.c:1.22	Fri Dec 13 21:46:59 2019
+++ src/usr.sbin/sysinst/disklabel.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.c,v 1.22 2019/12/13 21:46:59 martin Exp $	*/
+/*	$NetBSD: disklabel.c,v 1.23 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -636,7 +636,7 @@ disklabel_create_custom_part_type(const 
 }
 
 static const struct part_type_desc *
-disklabel_get_fs_part_type(unsigned fstype, unsigned subtype)
+disklabel_get_fs_part_type(enum part_type pt, unsigned fstype, unsigned subtype)
 {
 	return disklabel_find_type(fstype, false);
 }
Index: src/usr.sbin/sysinst/mbr.c
diff -u src/usr.sbin/sysinst/mbr.c:1.22 src/usr.sbin/sysinst/mbr.c:1.23
--- src/usr.sbin/sysinst/mbr.c:1.22	Tue Nov 12 16:33:14 2019
+++ src/usr.sbin/sysinst/mbr.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbr.c,v 1.22 2019/11/12 16:33:14 martin Exp $ */
+/*	$NetBSD: mbr.c,v 1.23 2019/12/13 22:12:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1046,7 +1046,7 @@ mbr_get_part_type_count(void)
 }
 
 static const struct part_type_desc *
-mbr_get_fs_part_type(unsigned fs_type, unsigned sub_type)
+mbr_get_fs_part_type(enum part_type pt, unsigned fs_type, unsigned sub_type)
 {
 	if (known_part_types == 0)
 		map_mbr_part_types();

Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.12 src/usr.sbin/sysinst/gpt.c:1.13
--- src/usr.sbin/sysinst/gpt.c:1.12	Tue Nov 12 16:33:14 2019
+++ src/usr.sbin/sysinst/gpt.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.c,v 1.12 2019/11/12 16:33:14 martin Exp $	*/
+/*	$NetBSD: gpt.c,v 1.13 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -874,10 +874,17 @@ gpt_find_type(const char *desc)
 }
 
 static const struct part_type_desc *
-gpt_get_fs_part_type(unsigned fstype, unsigned fs_sub_type)
+gpt_get_fs_part_type(enum part_type pt, unsigned fstype, unsigned fs_sub_type)
 {
 	size_t i;
 
+	/* Try with complet match (including part_type) first */
+	for (i = 0; i < __arraycount(gpt_fs_types); i++)
+		if (fstype == gpt_fs_types[i].fstype &&
+		    pt == gpt_fs_types[i].ptype)
+			return gpt_find_type(gpt_fs_types[i].name);
+
+	/* If that did not work, ignore part_type */
 	for (i = 0; i < __arraycount(gpt_fs_types); i++)
 		if (fstype == gpt_fs_types[i].fstype)
 			return gpt_find_type(gpt_fs_types[i].name);

Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.15 src/usr.sbin/sysinst/label.c:1.16
--- src/usr.sbin/sysinst/label.c:1.15	Wed Dec 11 19:23:37 2019
+++ src/usr.sbin/sysinst/label.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: label.c,v 1.15 2019/12/11 19:23:37 martin Exp $	*/
+/*	$NetBSD: label.c,v 1.16 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.15 2019/12/11 19:23:37 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.16 2019/12/13 22:12:41 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -487,6 +487,7 @@ set_fstype_ext(menudesc *menu, void *arg
 {
 	struct single_part_fs_edit *edit = arg;
 	size_t i, ndx, max = menu->numopts;
+	enum part_type pt;
 
 	if (menu->cursel == 0 || menu->cursel == 1) {
 		edit->info.fs_type = FS_BSDFFS;
@@ -516,8 +517,9 @@ set_fstype_ext(menudesc *menu, void *arg
 	return 1;
 
 found_type:
+	pt = edit->info.nat_type ? edit->info.nat_type->generic_ptype : PT_root;
 	edit->info.nat_type = edit->pset->parts->pscheme->
-	    get_fs_part_type(edit->info.fs_type, edit->info.fs_sub_type);
+	    get_fs_part_type(pt, edit->info.fs_type, edit->info.fs_sub_type);
 	if (edit->info.nat_type == NULL)
 		edit->info.nat_type = edit->pset->parts->pscheme->
 		    get_generic_part_type(PT_root);
@@ -603,13 +605,15 @@ static int
 set_fstype(menudesc *menu, void *arg)
 {
 	struct single_part_fs_edit *edit = arg;
+	enum part_type pt;
 	int ndx;
 
+	pt = edit->info.nat_type ? edit->info.nat_type->generic_ptype : PT_root;
 	if (menu->cursel < 2) {
 		edit->info.fs_type = FS_BSDFFS;
 		edit->info.fs_sub_type = menu->cursel == 0 ? 2 : 1;
 		edit->info.nat_type = edit->pset->parts->pscheme->
-		    get_fs_part_type(FS_BSDFFS, 2);
+		    get_fs_part_type(pt, FS_BSDFFS, 2);
 		if (edit->info.nat_type == NULL)
 			edit->info.nat_type = edit->pset->parts->
 			    pscheme->get_generic_part_type(PT_root);
@@ -627,7 +631,7 @@ set_fstype(menudesc *menu, void *arg)
 	edit->info.fs_type = edit_fs_common_types[ndx];
 	edit->info.fs_sub_type = 0;
 	edit->info.nat_type = edit->pset->parts->pscheme->
-	    get_fs_part_type(edit->info.fs_type, 0);
+	    get_fs_part_type(pt, edit->info.fs_type, 0);
 	if (edit->info.nat_type == NULL)
 		edit->info.nat_type = edit->pset->parts->
 		    pscheme->get_generic_part_type(PT_root);
@@ -800,7 +804,7 @@ edit_ptn(menudesc *menu, void *arg)
 			edit.info.fs_type = FS_BSDFFS;
 			edit.info.fs_sub_type = 2;
 			edit.info.nat_type = pset->parts->pscheme->
-			    get_fs_part_type(edit.info.fs_type,
+			    get_fs_part_type(PT_root, edit.info.fs_type,
 			    edit.info.fs_sub_type);
 			edit.wanted->instflags = PUIINST_NEWFS;
 		}

Index: src/usr.sbin/sysinst/partitions.c
diff -u src/usr.sbin/sysinst/partitions.c:1.6 src/usr.sbin/sysinst/partitions.c:1.7
--- src/usr.sbin/sysinst/partitions.c:1.6	Mon Dec  9 19:16:53 2019
+++ src/usr.sbin/sysinst/partitions.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: partitions.c,v 1.6 2019/12/09 19:16:53 martin Exp $	*/
+/*	$NetBSD: partitions.c,v 1.7 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -79,7 +79,9 @@ generic_adapt_foreign_part_info(const st
 		return false;
 
 	/* slightly simplistic, enhance when needed */
-	dest->nat_type = myself->pscheme->get_fs_part_type(dest->fs_type,
+	dest->nat_type = myself->pscheme->get_fs_part_type(
+	    dest->nat_type ? dest->nat_type->generic_ptype : PT_root,
+	    dest->fs_type,
 	    dest->fs_sub_type);
 	if (dest->nat_type == NULL)
 		dest->nat_type = myself->pscheme->get_generic_part_type(

Index: src/usr.sbin/sysinst/partitions.h
diff -u src/usr.sbin/sysinst/partitions.h:1.9 src/usr.sbin/sysinst/partitions.h:1.10
--- src/usr.sbin/sysinst/partitions.h:1.9	Mon Dec  9 19:16:53 2019
+++ src/usr.sbin/sysinst/partitions.h	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: partitions.h,v 1.9 2019/12/09 19:16:53 martin Exp $	*/
+/*	$NetBSD: partitions.h,v 1.10 2019/12/13 22:12:41 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -222,7 +222,8 @@ struct disk_partitioning_scheme {
 	 * Get the prefered native partition type for a specific file system
 	 * type (FS_*) and subtype (fs specific value)
 	 */
-	const struct part_type_desc * (*get_fs_part_type)(unsigned, unsigned);
+	const struct part_type_desc * (*get_fs_part_type)(
+	    enum part_type, unsigned, unsigned);
 	/*
 	 * Create a custom partition type. If the type already exists
 	 * (or there is a collision), the old existing type will be

Index: src/usr.sbin/sysinst/partman.c
diff -u src/usr.sbin/sysinst/partman.c:1.44 src/usr.sbin/sysinst/partman.c:1.45
--- src/usr.sbin/sysinst/partman.c:1.44	Sat Nov 16 20:26:59 2019
+++ src/usr.sbin/sysinst/partman.c	Fri Dec 13 22:12:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: partman.c,v 1.44 2019/11/16 20:26:59 martin Exp $ */
+/*	$NetBSD: partman.c,v 1.45 2019/12/13 22:12:41 martin Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -2191,7 +2191,8 @@ pm_setfstype(struct pm_devs *pm_cur, par
 	if (!pm_cur->parts->pscheme->get_part_info(pm_cur->parts, id, &info))
 		return;
 
-	info.nat_type = pm_cur->parts->pscheme->get_fs_part_type(fstype, fs_subtype);
+	info.nat_type = pm_cur->parts->pscheme->get_fs_part_type(PT_root,
+	    fstype, fs_subtype);
 	if (info.nat_type == NULL)
 		return;
 	info.fs_type = fstype;

Reply via email to