Module Name: src
Committed By: martin
Date: Tue Oct 13 10:43:23 UTC 2020
Modified Files:
src/usr.sbin/sysinst: bsddisklabel.c
Log Message:
Before forcing MBR partitions into our disklabel, make sure they are not
there yet - could happen in various paths when reusing existing partitions
(or parts of that) - previously we would blindly duplicate identical
partitions.
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/sysinst/bsddisklabel.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.53 src/usr.sbin/sysinst/bsddisklabel.c:1.54
--- src/usr.sbin/sysinst/bsddisklabel.c:1.53 Mon Oct 12 16:27:23 2020
+++ src/usr.sbin/sysinst/bsddisklabel.c Tue Oct 13 10:43:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bsddisklabel.c,v 1.53 2020/10/12 16:27:23 martin Exp $ */
+/* $NetBSD: bsddisklabel.c,v 1.54 2020/10/13 10:43:23 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -1615,26 +1615,44 @@ apply_settings_to_partitions(struct disk
(PUIFLG_ADD_INNER|PUIFLG_IS_OUTER))
continue;
- infos[i].start = want->cur_start;
- infos[i].size = want->size;
- infos[i].nat_type = wanted->parts->pscheme->get_fs_part_type(
- 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;
-
- if (wanted->parts->pscheme->add_outer_partition
- != NULL)
- new_part_id = wanted->parts->pscheme->
- add_outer_partition(
- wanted->parts, &infos[i], NULL);
- else
- new_part_id = wanted->parts->pscheme->
- add_partition(
- wanted->parts, &infos[i], NULL);
+ new_part_id = NO_PART;
+ for (part_id j = 0; new_part_id == NO_PART &&
+ j < wanted->parts->num_part; j++) {
+ struct disk_part_info test;
+
+ if (!wanted->parts->pscheme->get_part_info(
+ wanted->parts, j, &test))
+ continue;
+ if (test.start == want->cur_start &&
+ test.size == want->size)
+ new_part_id = j;
+ }
+
+ if (new_part_id == NO_PART) {
+ infos[i].start = want->cur_start;
+ infos[i].size = want->size;
+ infos[i].nat_type = wanted->parts->pscheme->
+ get_fs_part_type(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;
+ infos[i].fs_opt1 = want->fs_opt1;
+ infos[i].fs_opt2 = want->fs_opt2;
+
+ if (wanted->parts->pscheme->add_outer_partition
+ != NULL)
+ new_part_id = wanted->parts->pscheme->
+ add_outer_partition(
+ wanted->parts, &infos[i], NULL);
+ else
+ new_part_id = wanted->parts->pscheme->
+ add_partition(
+ wanted->parts, &infos[i], NULL);
- if (new_part_id == NO_PART)
- continue; /* failed to add, skip */
+ if (new_part_id == NO_PART)
+ continue; /* failed to add, skip */
+ }
wanted->parts->pscheme->get_part_info(
wanted->parts, new_part_id, &infos[i]);