summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorStuart Henderson <sthen@cvs.openbsd.org>2015-05-08 12:15:51 +0000
committerStuart Henderson <sthen@cvs.openbsd.org>2015-05-08 12:15:51 +0000
commitb0aa2a1ff4f535b1c42884d2dc1142cc6b9402ba (patch)
tree6cc7d71fed1c72547d29774793df89a7985e1189 /sbin/disklabel
parent8cad269f183023ebb4107b587fd55edadbf0c487 (diff)
Separately track the number of items in alloc_table in a variable. With
the changes for handling template files in r1.293, alloc_table became a pointer to an array of structs (rather than the array itself), so nitems(alloc_table) no longer returns the number of elements. As found by sebastia@, autosize would only try the first allocation scheme, so installation would fail on small disks. ok henning@
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/editor.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 41ef9714072..83cc8a79aeb 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.294 2015/04/29 16:46:39 henning Exp $ */
+/* $OpenBSD: editor.c,v 1.295 2015/05/08 12:15:50 sthen Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -123,6 +123,7 @@ struct alloc_table alloc_table_default[] = {
{ alloc_stupid, nitems(alloc_stupid) }
};
struct alloc_table *alloc_table = alloc_table_default;
+int alloc_table_nitems = 4;
void edit_parms(struct disklabel *);
void editor_resize(struct disklabel *, char *);
@@ -614,7 +615,7 @@ again:
if (j == MAXPARTITIONS) {
/* It did not work out, try next strategy */
free(alloc);
- if (++index < nitems(alloc_table))
+ if (++index < alloc_table_nitems)
goto again;
else
return;
@@ -677,7 +678,7 @@ cylinderalign:
if (secs < ap->minsz) {
/* It did not work out, try next strategy */
free(alloc);
- if (++index < nitems(alloc_table))
+ if (++index < alloc_table_nitems)
goto again;
else
return;
@@ -2385,6 +2386,7 @@ parse_autotable(char *filename)
err(1, "%s", filename);
if ((alloc_table = calloc(1, sizeof(struct alloc_table))) == NULL)
err(1, NULL);
+ alloc_table_nitems = 1;
while ((buf = fgetln(cfile, &len)) != NULL) {
if ((alloc_table[0].table = reallocarray(alloc_table[0].table,