Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst When finding (paritioning scheme native) pa...



details:   https://anonhg.NetBSD.org/src/rev/9498839ae9f2
branches:  trunk
changeset: 466143:9498839ae9f2
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Dec 13 22:12:41 2019 +0000

description:
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.

diffstat:

 usr.sbin/sysinst/bsddisklabel.c |   8 ++++----
 usr.sbin/sysinst/disklabel.c    |   4 ++--
 usr.sbin/sysinst/gpt.c          |  11 +++++++++--
 usr.sbin/sysinst/label.c        |  16 ++++++++++------
 usr.sbin/sysinst/mbr.c          |   4 ++--
 usr.sbin/sysinst/partitions.c   |   6 ++++--
 usr.sbin/sysinst/partitions.h   |   5 +++--
 usr.sbin/sysinst/partman.c      |   5 +++--
 8 files changed, 37 insertions(+), 22 deletions(-)

diffs (230 lines):

diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/bsddisklabel.c
--- a/usr.sbin/sysinst/bsddisklabel.c   Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/bsddisklabel.c   Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
                        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 @@
                        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 @@
                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;
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
 }
 
 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);
 }
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/gpt.c
--- a/usr.sbin/sysinst/gpt.c    Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/gpt.c    Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
 }
 
 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);
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/label.c
--- a/usr.sbin/sysinst/label.c  Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/label.c  Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
 {
        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 @@
        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 @@
 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 @@
        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.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;
                }
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/mbr.c
--- a/usr.sbin/sysinst/mbr.c    Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/mbr.c    Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
 }
 
 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();
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/partitions.c
--- a/usr.sbin/sysinst/partitions.c     Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/partitions.c     Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
                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(
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/partitions.h
--- a/usr.sbin/sysinst/partitions.h     Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/partitions.h     Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
         * 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
diff -r 74a5f66fee02 -r 9498839ae9f2 usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Fri Dec 13 22:10:21 2019 +0000
+++ b/usr.sbin/sysinst/partman.c        Fri Dec 13 22:12:41 2019 +0000
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index