Tue Jan 21 20:04:30 2020 UTC ()
Deal with even stranger fictious empty disklabels (PR kern/54882).


(martin)
diff -r1.32 -r1.33 src/usr.sbin/sysinst/disklabel.c

cvs diff -r1.32 -r1.33 src/usr.sbin/sysinst/disklabel.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/disklabel.c 2020/01/21 06:44:40 1.32
+++ src/usr.sbin/sysinst/disklabel.c 2020/01/21 20:04:30 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: disklabel.c,v 1.32 2020/01/21 06:44:40 mrg Exp $ */ 1/* $NetBSD: disklabel.c,v 1.33 2020/01/21 20:04:30 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 2018 The NetBSD Foundation, Inc. 4 * Copyright 2018 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.
@@ -292,27 +292,27 @@ disklabel_parts_read(const char *disk, d @@ -292,27 +292,27 @@ disklabel_parts_read(const char *disk, d
292 292
293 if (parts->l.d_npartitions <= RAW_PART || 293 if (parts->l.d_npartitions <= RAW_PART ||
294 parts->l.d_partitions[RAW_PART].p_size == 0) 294 parts->l.d_partitions[RAW_PART].p_size == 0)
295 goto no_valid_label; 295 goto no_valid_label;
296 296
297 /* 297 /*
298 * Check if kernel translation gave us "something" besides 298 * Check if kernel translation gave us "something" besides
299 * the raw or the whole-disk partition. 299 * the raw or the whole-disk partition.
300 * If not: report missing disklabel. 300 * If not: report missing disklabel.
301 */ 301 */
302 for (int part = 0; part < parts->l.d_npartitions; part++) { 302 for (int part = 0; part < parts->l.d_npartitions; part++) {
303 if (parts->l.d_partitions[part].p_fstype == FS_UNUSED) 303 if (parts->l.d_partitions[part].p_fstype == FS_UNUSED)
304 continue; 304 continue;
305 if (part == 0 && 305 if (/* part == 0 && */ /* PR kern/54882 */
306 parts->l.d_partitions[part].p_offset == 306 parts->l.d_partitions[part].p_offset ==
307 parts->l.d_partitions[RAW_PART].p_offset && 307 parts->l.d_partitions[RAW_PART].p_offset &&
308 parts->l.d_partitions[part].p_size == 308 parts->l.d_partitions[part].p_size ==
309 parts->l.d_partitions[RAW_PART].p_size) 309 parts->l.d_partitions[RAW_PART].p_size)
310 continue; 310 continue;
311 if (part == RAW_PART) 311 if (part == RAW_PART)
312 continue; 312 continue;
313 found_real_part = true; 313 found_real_part = true;
314 break; 314 break;
315 } 315 }
316 if (!found_real_part) { 316 if (!found_real_part) {
317 /* no partion there yet */ 317 /* no partion there yet */
318no_valid_label: 318no_valid_label: