Sun Jul 28 16:03:00 2019 UTC ()
When merging existing partitions into the planned installation partitions,
keep the separation between the original planned partitions and the
pre-exiting partitions.
Also do not call found partitions "outer" if they are not (but could be)


(martin)
diff -r1.21 -r1.22 src/usr.sbin/sysinst/bsddisklabel.c

cvs diff -r1.21 -r1.22 src/usr.sbin/sysinst/bsddisklabel.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/bsddisklabel.c 2019/07/15 19:13:05 1.21
+++ src/usr.sbin/sysinst/bsddisklabel.c 2019/07/28 16:03:00 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bsddisklabel.c,v 1.21 2019/07/15 19:13:05 martin Exp $ */ 1/* $NetBSD: bsddisklabel.c,v 1.22 2019/07/28 16:03:00 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on code written by Philip A. Nelson for Piermont Information 7 * Based on code written by Philip A. Nelson for Piermont Information
8 * Systems Inc. 8 * Systems Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -894,51 +894,54 @@ ask_layout(struct disk_partitions *parts @@ -894,51 +894,54 @@ ask_layout(struct disk_partitions *parts
894 -1, -10, 0, 0, MC_NOEXITOPT, NULL, NULL, NULL, NULL, NULL); 894 -1, -10, 0, 0, MC_NOEXITOPT, NULL, NULL, NULL, NULL, NULL);
895 if (menu != -1) { 895 if (menu != -1) {
896 get_menudesc(menu)->expand_act = expand_all_option_texts; 896 get_menudesc(menu)->expand_act = expand_all_option_texts;
897 process_menu(menu, &ai); 897 process_menu(menu, &ai);
898 free_menu(menu); 898 free_menu(menu);
899 } 899 }
900 900
901 return ai.rv; 901 return ai.rv;
902} 902}
903 903
904static void 904static void
905merge_part_with_wanted(struct disk_partitions *parts, part_id pno, 905merge_part_with_wanted(struct disk_partitions *parts, part_id pno,
906 const struct disk_part_info *info, struct partition_usage_set *wanted, 906 const struct disk_part_info *info, struct partition_usage_set *wanted,
907 bool is_outer) 907 size_t wanted_num, bool is_outer)
908{ 908{
909 struct part_usage_info *infos; 909 struct part_usage_info *infos;
910 910
911 /* 911 /*
912 * does this partition match something in the wanted set? 912 * does this partition match something in the wanted set?
913 */ 913 */
914 for (size_t i = 0; i < wanted->num; i++) { 914 for (size_t i = 0; i < wanted_num; i++) {
915 if (wanted->infos[i].type != info->nat_type->generic_ptype) 915 if (wanted->infos[i].type != info->nat_type->generic_ptype)
916 continue; 916 continue;
917 if (info->last_mounted != NULL && info->last_mounted[0] != 0 && 917 if (wanted->infos[i].type == PT_root &&
 918 info->last_mounted != NULL && info->last_mounted[0] != 0 &&
918 strcmp(info->last_mounted, wanted->infos[i].mount) != 0) 919 strcmp(info->last_mounted, wanted->infos[i].mount) != 0)
919 continue; 920 continue;
920 if (wanted->infos[i].cur_part_id != NO_PART) 921 if (wanted->infos[i].cur_part_id != NO_PART)
921 continue; 922 continue;
922 wanted->infos[i].cur_part_id = pno; 923 wanted->infos[i].cur_part_id = pno;
923 wanted->infos[i].parts = parts; 924 wanted->infos[i].parts = parts;
924 wanted->infos[i].size = info->size; 925 wanted->infos[i].size = info->size;
925 wanted->infos[i].cur_start = info->start; 926 wanted->infos[i].cur_start = info->start;
926 wanted->infos[i].flags &= ~PUIFLAG_EXTEND; 927 wanted->infos[i].flags &= ~PUIFLAG_EXTEND;
927 if (wanted->infos[i].fs_type != FS_UNUSED && 928 if (wanted->infos[i].fs_type != FS_UNUSED &&
928 wanted->infos[i].type != PT_swap) 929 wanted->infos[i].type != PT_swap)
929 wanted->infos[i].instflags |= PUIINST_MOUNT; 930 wanted->infos[i].instflags |= PUIINST_MOUNT;
930 if (is_outer) 931 if (is_outer)
931 wanted->infos[i].flags |= PUIFLG_IS_OUTER; 932 wanted->infos[i].flags |= PUIFLG_IS_OUTER;
 933 else
 934 wanted->infos[i].flags &= ~PUIFLG_IS_OUTER;
932 return; 935 return;
933 } 936 }
934 937
935 /* 938 /*
936 * no match - if this is fromt the outer scheme, we are done. 939 * no match - if this is fromt the outer scheme, we are done.
937 * otherwise it must be inserted into the wanted set. 940 * otherwise it must be inserted into the wanted set.
938 */ 941 */
939 if (is_outer) 942 if (is_outer)
940 return; 943 return;
941 944
942 /* 945 /*
943 * create a new entry for this 946 * create a new entry for this
944 */ 947 */
@@ -1040,56 +1043,57 @@ fill_defaults(struct partition_usage_set @@ -1040,56 +1043,57 @@ fill_defaults(struct partition_usage_set
1040 wanted->infos[i].size == 0) 1043 wanted->infos[i].size == 0)
1041 /* default tmpfs to 1/4 RAM */ 1044 /* default tmpfs to 1/4 RAM */
1042 wanted->infos[i].def_size = 1045 wanted->infos[i].def_size =
1043 get_ramsize() * (MEG/512/4); 1046 get_ramsize() * (MEG/512/4);
1044 } 1047 }
1045 1048
1046 /* 1049 /*
1047 * Now we have the defaults as if we were installing to an 1050 * Now we have the defaults as if we were installing to an
1048 * empty disk. Merge the partitions in target range that are already 1051 * empty disk. Merge the partitions in target range that are already
1049 * there (match with wanted) or are there additionaly. 1052 * there (match with wanted) or are there additionaly.
1050 * The only thing outside of target range that we care for 1053 * The only thing outside of target range that we care for
1051 * is a potential swap partition - we assume one is enough. 1054 * is a potential swap partition - we assume one is enough.
1052 */ 1055 */
 1056 size_t num = wanted->num;
1053 if (parts->parent) { 1057 if (parts->parent) {
1054 for (part_id pno = 0; pno < parts->parent->num_part; pno++) { 1058 for (part_id pno = 0; pno < parts->parent->num_part; pno++) {
1055 struct disk_part_info info; 1059 struct disk_part_info info;
1056 1060
1057 if (!parts->parent->pscheme->get_part_info( 1061 if (!parts->parent->pscheme->get_part_info(
1058 parts->parent, pno, &info)) 1062 parts->parent, pno, &info))
1059 continue; 1063 continue;
1060 if (info.nat_type->generic_ptype != PT_swap) 1064 if (info.nat_type->generic_ptype != PT_swap)
1061 continue; 1065 continue;
1062 merge_part_with_wanted(parts->parent, pno, &info, 1066 merge_part_with_wanted(parts->parent, pno, &info,
1063 wanted, true); 1067 wanted, num, true);
1064 break; 1068 break;
1065 } 1069 }
1066 } 1070 }
1067 for (part_id pno = 0; pno < parts->num_part; pno++) { 1071 for (part_id pno = 0; pno < parts->num_part; pno++) {
1068 struct disk_part_info info; 1072 struct disk_part_info info;
1069 1073
1070 if (!parts->pscheme->get_part_info(parts, pno, &info)) 1074 if (!parts->pscheme->get_part_info(parts, pno, &info))
1071 continue; 1075 continue;
1072 1076
1073 if (info.flags & PTI_PSCHEME_INTERNAL) 1077 if (info.flags & PTI_PSCHEME_INTERNAL)
1074 continue; 1078 continue;
1075 1079
1076 if (info.nat_type->generic_ptype != PT_swap && 1080 if (info.nat_type->generic_ptype != PT_swap &&
1077 (info.start < ptstart || 1081 (info.start < ptstart ||
1078 (info.start + info.size) > (ptstart+ptsize))) 1082 (info.start + info.size) > (ptstart+ptsize)))
1079 continue; 1083 continue;
1080 1084
1081 merge_part_with_wanted(parts, pno, &info, 1085 merge_part_with_wanted(parts, pno, &info,
1082 wanted, false); 1086 wanted, num, false);
1083 } 1087 }
1084 1088
1085 daddr_t align = parts->pscheme->get_part_alignment(parts); 1089 daddr_t align = parts->pscheme->get_part_alignment(parts);
1086 1090
1087 if (root < wanted->num && wanted->infos[root].cur_part_id == NO_PART) { 1091 if (root < wanted->num && wanted->infos[root].cur_part_id == NO_PART) {
1088 daddr_t max_root_size = parts->disk_start + parts->disk_size; 1092 daddr_t max_root_size = parts->disk_start + parts->disk_size;
1089 if (root_limit > 0) { 1093 if (root_limit > 0) {
1090 /* Bah - bios can not read all the disk, limit root */ 1094 /* Bah - bios can not read all the disk, limit root */
1091 max_root_size = root_limit - parts->disk_start; 1095 max_root_size = root_limit - parts->disk_start;
1092 } 1096 }
1093 wanted->infos[root].limit = max_root_size; 1097 wanted->infos[root].limit = max_root_size;
1094 } 1098 }
1095 1099