Module Name: src Committed By: snj Date: Sat Dec 31 05:03:14 UTC 2022
Modified Files: src/usr.sbin/sysinst [netbsd-9]: disklabel.c label.c Log Message: Pull up following revision(s) (requested by martin in ticket #1558): usr.sbin/sysinst/disklabel.c: 1.46-1.48 usr.sbin/sysinst/label.c: 1.40-1.41 disklabel_can_add_partition() did not consider additional partitions (while there still is space in the disklabel). Part of PR 56886. Fix free space accounting for partition size changes and deletions. Part of PR 56886. renumber_partitions() needs to deal with removed/added partitions. Fix free space accounting when partitions change size or are deleted. Part of PR 56886. Fix inverted condition in previous and only apply special handling for the "all of NetBSD" partition when we have an outer MBR label. Pointed out by Izumi Tsutsui. Hopefully the last fix needed for PR 56886. To generate a diff of this commit: cvs rdiff -u -r1.10.2.10 -r1.10.2.11 src/usr.sbin/sysinst/disklabel.c cvs rdiff -u -r1.10.2.8 -r1.10.2.9 src/usr.sbin/sysinst/label.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/disklabel.c diff -u src/usr.sbin/sysinst/disklabel.c:1.10.2.10 src/usr.sbin/sysinst/disklabel.c:1.10.2.11 --- src/usr.sbin/sysinst/disklabel.c:1.10.2.10 Thu Oct 15 19:36:50 2020 +++ src/usr.sbin/sysinst/disklabel.c Sat Dec 31 05:03:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.10.2.10 2020/10/15 19:36:50 bouyer Exp $ */ +/* $NetBSD: disklabel.c,v 1.10.2.11 2022/12/31 05:03:14 snj Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -520,6 +520,8 @@ disklabel_delete(struct disk_partitions if (parts->install_target == parts->l.d_partitions[part].p_offset) parts->install_target = -1; + parts->dp.free_space += + parts->l.d_partitions[part].p_size; parts->l.d_partitions[part].p_size = 0; parts->l.d_partitions[part].p_offset = 0; parts->l.d_partitions[part].p_fstype = FS_UNUSED; @@ -821,6 +823,16 @@ disklabel_set_part_info(struct disk_part was_inst_target = parts->l.d_partitions[part].p_offset == parts->install_target; parts->l.d_partitions[part].p_offset = info->start; + if (part != RAW_PART +#if RAW_PART == 3 + && (part != RAW_PART-1 || + parts->dp.parent == NULL) +#endif + ) { + parts->dp.free_space += + parts->l.d_partitions[part].p_size - + info->size; + } parts->l.d_partitions[part].p_size = info->size; parts->l.d_partitions[part].p_fstype = dl_part_type_from_generic(info->nat_type); @@ -939,7 +951,8 @@ disklabel_can_add_partition(const struct if (disklabel_get_free_spaces_internal(parts, &space, 1, parts->ptn_alignment, parts->ptn_alignment, 0, -1) < 1) return false; - + if (parts->l.d_npartitions < dl_maxpart) + return true; for (i = 0; i < parts->l.d_npartitions; i++) { if (i == RAW_PART) continue; Index: src/usr.sbin/sysinst/label.c diff -u src/usr.sbin/sysinst/label.c:1.10.2.8 src/usr.sbin/sysinst/label.c:1.10.2.9 --- src/usr.sbin/sysinst/label.c:1.10.2.8 Wed Jun 22 23:48:54 2022 +++ src/usr.sbin/sysinst/label.c Sat Dec 31 05:03:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: label.c,v 1.10.2.8 2022/06/22 23:48:54 msaitoh Exp $ */ +/* $NetBSD: label.c,v 1.10.2.9 2022/12/31 05:03:14 snj 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.10.2.8 2022/06/22 23:48:54 msaitoh Exp $"); +__RCSID("$NetBSD: label.c,v 1.10.2.9 2022/12/31 05:03:14 snj Exp $"); #endif #include <sys/types.h> @@ -505,7 +505,7 @@ renumber_partitions(struct partition_usa if (!pset->parts->pscheme->get_part_info(pset->parts, pno, &info)) continue; - for (i = 0; i < pset->parts->num_part; i++) { + for (i = 0; i < pset->num; i++) { if (pset->infos[i].cur_start != info.start) continue; if (pset->infos[i].cur_flags != info.flags) @@ -522,8 +522,9 @@ renumber_partitions(struct partition_usa } } - memcpy(pset->infos, ninfos, sizeof(*pset->infos)*pset->parts->num_part); - free(ninfos); + free(pset->infos); + pset->infos = ninfos; + pset->num = pset->parts->num_part; } /* @@ -980,6 +981,9 @@ edit_ptn(menudesc *menu, void *arg) if (!pset->parts->pscheme->set_part_info(pset->parts, edit.id, &edit.info, &err)) err_msg_win(err); + else + pset->cur_free_space += edit.old_info.size - + edit.info.size; } /* @@ -1009,7 +1013,7 @@ edit_ptn(menudesc *menu, void *arg) } remember_deleted(pset, pset->infos[edit.index].parts); - pset->cur_free_space += pset->infos[edit.index].size; + pset->cur_free_space += edit.info.size; memmove(pset->infos+edit.index, pset->infos+edit.index+1, sizeof(*pset->infos)*(pset->num-edit.index));