| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: part_edit.c,v 1.5 2019/06/22 20:46:07 christos Exp $ */ | | 1 | /* $NetBSD: part_edit.c,v 1.6 2019/07/09 16:14:46 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2019 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -1075,74 +1075,77 @@ ask_outer_partsizes(struct disk_partitio | | | @@ -1075,74 +1075,77 @@ ask_outer_partsizes(struct disk_partitio |
1075 | } | | 1075 | } |
1076 | | | 1076 | |
1077 | bool | | 1077 | bool |
1078 | edit_outer_parts(struct disk_partitions *parts) | | 1078 | edit_outer_parts(struct disk_partitions *parts) |
1079 | { | | 1079 | { |
1080 | part_id i; | | 1080 | part_id i; |
1081 | enum layout_type layout; | | 1081 | enum layout_type layout; |
1082 | int num_foreign_parts; | | 1082 | int num_foreign_parts; |
1083 | | | 1083 | |
1084 | /* If targeting a wedge, do not ask for further partitioning */ | | 1084 | /* If targeting a wedge, do not ask for further partitioning */ |
1085 | if (pm && (pm->no_part || pm->no_mbr)) | | 1085 | if (pm && (pm->no_part || pm->no_mbr)) |
1086 | return true; | | 1086 | return true; |
1087 | | | 1087 | |
1088 | /* Make sure pm has been properly initialized */ | | 1088 | /* Make sure parts has been properly initialized */ |
1089 | assert(pm->parts && pm->parts->pscheme); | | 1089 | assert(parts && parts->pscheme); |
1090 | | | 1090 | |
1091 | if (partman_go) | | 1091 | if (parts->pscheme->secondary_scheme == NULL) |
| | | 1092 | return true; /* no outer parts */ |
| | | 1093 | |
| | | 1094 | if (partman_go) { |
1092 | layout = LY_SETSIZES; | | 1095 | layout = LY_SETSIZES; |
1093 | else { | | 1096 | } else { |
1094 | /* Ask full/part */ | | 1097 | /* Ask full/part */ |
1095 | const struct disk_partitioning_scheme *sec = | | 1098 | const struct disk_partitioning_scheme *sec = |
1096 | pm->parts->pscheme->secondary_scheme; | | 1099 | parts->pscheme->secondary_scheme; |
1097 | | | | |
1098 | assert(sec != NULL); | | | |
1099 | | | 1100 | |
1100 | uint64_t m_size = | | 1101 | uint64_t m_size = |
1101 | DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB; | | 1102 | DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB; |
1102 | char min_size[5], build_size[5]; | | 1103 | char min_size[5], build_size[5]; |
1103 | const char | | 1104 | const char |
1104 | *prim_name = msg_string(pm->parts->pscheme->name), | | 1105 | *prim_name = msg_string(parts->pscheme->name), |
1105 | *prim_short = msg_string(pm->parts->pscheme->short_name), | | 1106 | *prim_short = msg_string(parts->pscheme->short_name), |
1106 | *sec_name = msg_string(sec->name), | | 1107 | *sec_name = msg_string(sec->name), |
1107 | *sec_short = msg_string(sec->short_name); | | 1108 | *sec_short = msg_string(sec->short_name); |
1108 | | | 1109 | |
1109 | humanize_number(min_size, sizeof(min_size), | | 1110 | humanize_number(min_size, sizeof(min_size), |
1110 | m_size * MEG, | | 1111 | m_size * MEG, |
1111 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); | | 1112 | "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); |
1112 | humanize_number(build_size, sizeof(build_size), | | 1113 | humanize_number(build_size, sizeof(build_size), |
1113 | SYSTEM_BUILD_SIZE * MEG, "", HN_AUTOSCALE, | | 1114 | SYSTEM_BUILD_SIZE * MEG, "", HN_AUTOSCALE, |
1114 | HN_B | HN_NOSPACE | HN_DECIMAL); | | 1115 | HN_B | HN_NOSPACE | HN_DECIMAL); |
1115 | | | 1116 | |
1116 | msg_display_subst(MSG_fullpart, 7, | | 1117 | msg_display_subst(MSG_fullpart, 7, |
1117 | pm->diskdev, | | 1118 | pm->diskdev, |
1118 | prim_name, sec_name, | | 1119 | prim_name, sec_name, |
1119 | prim_short, sec_short, | | 1120 | prim_short, sec_short, |
1120 | min_size, build_size); | | 1121 | min_size, build_size); |
1121 | msg_display_add("\n\n"); | | 1122 | msg_display_add("\n\n"); |
1122 | | | 1123 | |
1123 | layout = ask_fullpart(pm->parts); | | 1124 | layout = ask_fullpart(parts); |
1124 | } | | 1125 | } |
1125 | | | 1126 | |
1126 | if (layout == LY_USEFULL) { | | 1127 | if (layout == LY_USEFULL) { |
1127 | struct disk_part_info info; | | 1128 | struct disk_part_info info; |
1128 | | | 1129 | |
1129 | /* Count nonempty, non-BSD partitions. */ | | 1130 | /* Count nonempty, non-BSD partitions. */ |
1130 | num_foreign_parts = 0; | | 1131 | num_foreign_parts = 0; |
1131 | for (i = 0; i < parts->num_part; i++) { | | 1132 | for (i = 0; i < parts->num_part; i++) { |
1132 | if (!parts->pscheme->get_part_info(parts, i, &info)) | | 1133 | if (!parts->pscheme->get_part_info(parts, i, &info)) |
1133 | continue; | | 1134 | continue; |
1134 | if (info.size == 0) | | 1135 | if (info.size == 0) |
1135 | continue; | | 1136 | continue; |
| | | 1137 | if (info.flags & (PTI_PSCHEME_INTERNAL|PTI_RAW_PART)) |
| | | 1138 | continue; |
1136 | if (info.nat_type != NULL | | 1139 | if (info.nat_type != NULL |
1137 | && info.nat_type->generic_ptype != PT_root | | 1140 | && info.nat_type->generic_ptype != PT_root |
1138 | && info.nat_type->generic_ptype != PT_swap) | | 1141 | && info.nat_type->generic_ptype != PT_swap) |
1139 | num_foreign_parts++; | | 1142 | num_foreign_parts++; |
1140 | } | | 1143 | } |
1141 | | | 1144 | |
1142 | /* Ask if we really want to blow away non-NetBSD stuff */ | | 1145 | /* Ask if we really want to blow away non-NetBSD stuff */ |
1143 | if (num_foreign_parts > 0) { | | 1146 | if (num_foreign_parts > 0) { |
1144 | msg_display(MSG_ovrwrite); | | 1147 | msg_display(MSG_ovrwrite); |
1145 | if (!ask_noyes(NULL)) { | | 1148 | if (!ask_noyes(NULL)) { |
1146 | if (logfp) | | 1149 | if (logfp) |
1147 | (void)fprintf(logfp, | | 1150 | (void)fprintf(logfp, |
1148 | "User answered no to destroy " | | 1151 | "User answered no to destroy " |