From: krw Date: Thu, 29 Jun 2023 20:10:11 +0000 (+0000) Subject: Fix handling of 'N-* 100' template entries. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=775a2993fc20fcd3fe445b0d94afa6ec4ae8500a;p=openbsd Fix handling of 'N-* 100' template entries. 'N-* 100' means a max of all 'extra' disk space not all disk space. Fixes templates with partitions after a 'N-* 100' entry. Reported by anton@ --- diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index a84900331dc..998f994aa4d 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.412 2023/06/28 12:12:48 krw Exp $ */ +/* $OpenBSD: editor.c,v 1.413 2023/06/29 20:10:11 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller @@ -677,11 +677,12 @@ allocate_space(struct disklabel *lp, const struct alloc_table *alloc_table) mpfree(mountpoints, KEEP); for (i = 0; i < alloc_table->sz; i++) { - if (sa[i].rate < 100) { + if (sa[i].rate == 100) + maxsz = sa[i].minsz + xtrablks; + else maxsz = sa[i].minsz + (xtrablks / 100) * sa[i].rate; - if (maxsz < sa[i].maxsz) - sa[i].maxsz = maxsz; - } + if (maxsz < sa[i].maxsz) + sa[i].maxsz = maxsz; if (allocate_partition(lp, &sa[i])) { mpfree(mountpoints, KEEP); return 1;