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.
This commit is contained in:
martin 2019-12-13 22:12:41 +00:00
parent 2eadf7ff31
commit 194b0d85bc
8 changed files with 37 additions and 22 deletions

View File

@ -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_devs *p, struct disk_partitions *parts,
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_devs *p, struct disk_partitions *parts,
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_devs *p, struct disk_partitions *parts,
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;

View File

@ -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 char *custom, const char **err_msg)
}
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);
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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();

View File

@ -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 struct disk_partitions *myself,
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(

View File

@ -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

View File

@ -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, part_id id, int fstype, int fs_subtype)
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;