Module Name: src Committed By: martin Date: Thu Dec 12 12:19:39 UTC 2019
Modified Files: src/usr.sbin/sysinst: disklabel.c Log Message: Fix detection of existing disklabels in the case when we only have the disklabel partitioning scheme available. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sysinst/disklabel.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.18 src/usr.sbin/sysinst/disklabel.c:1.19 --- src/usr.sbin/sysinst/disklabel.c:1.18 Mon Dec 9 19:16:53 2019 +++ src/usr.sbin/sysinst/disklabel.c Thu Dec 12 12:19:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.c,v 1.18 2019/12/09 19:16:53 martin Exp $ */ +/* $NetBSD: disklabel.c,v 1.19 2019/12/12 12:19:39 martin Exp $ */ /* * Copyright 2018 The NetBSD Foundation, Inc. @@ -170,17 +170,16 @@ disklabel_parts_read(const char *disk, d int fd; char diskpath[MAXPATHLEN]; uint flags; + bool only_dl = only_have_disklabel(); + bool have_raw_label = false; #ifndef DISKLABEL_NO_ONDISK_VERIFY - if (!only_have_disklabel()) { - /* - * If there are alternative partitioning schemes, - * verify we really have a disklabel. - */ - if (run_program(RUN_SILENT | RUN_ERROR_OK, - "disklabel -r %s", disk) != 0) - return NULL; - } + /* + * Verify we really have a disklabel. + */ + if (run_program(RUN_SILENT | RUN_ERROR_OK, + "disklabel -r %s", disk) == 0) + have_raw_label = true; #endif /* read partitions */ @@ -267,6 +266,29 @@ disklabel_parts_read(const char *disk, d } close(fd); + if (!have_raw_label && only_dl) { + bool found_real_part = false; + + /* + * Check if kernel translation gave us "something" besides + * the raw or the whole-disk partition. + * If not: report missing disklabel. + */ + for (int part = 0; part < parts->l.d_npartitions; part++) { + if (parts->l.d_partitions[part].p_fstype == FS_UNUSED) + continue; + if (part == RAW_PART) + continue; + found_real_part = true; + break; + } + if (!found_real_part) { + /* no partion there yet */ + free(parts); + return NULL; + } + } + return &parts->dp; }