Sat Jun 15 07:57:39 2019 UTC ()
After deleting all partitions, reset alignment to the values we would
have used on an empty disk.


(martin)
diff -r1.11 -r1.12 src/usr.sbin/sysinst/mbr.c

cvs diff -r1.11 -r1.12 src/usr.sbin/sysinst/mbr.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/mbr.c 2019/06/12 06:20:17 1.11
+++ src/usr.sbin/sysinst/mbr.c 2019/06/15 07:57:38 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mbr.c,v 1.11 2019/06/12 06:20:17 martin Exp $ */ 1/* $NetBSD: mbr.c,v 1.12 2019/06/15 07:57:38 martin Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Philip A. Nelson for Piermont Information Systems Inc. 7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -1674,26 +1674,35 @@ mbr_delete_all(struct disk_partitions *a @@ -1674,26 +1674,35 @@ mbr_delete_all(struct disk_partitions *a
1674 mbr_info_t *ext; 1674 mbr_info_t *ext;
1675 struct mbr_partition *part; 1675 struct mbr_partition *part;
1676 1676
1677 part = &mbrs->mbr_parts[0]; 1677 part = &mbrs->mbr_parts[0];
1678 /* Set the partition information for full disk usage. */ 1678 /* Set the partition information for full disk usage. */
1679 while ((ext = mbri->extended)) { 1679 while ((ext = mbri->extended)) {
1680 mbri->extended = ext->extended; 1680 mbri->extended = ext->extended;
1681 free_mbr_info(ext); 1681 free_mbr_info(ext);
1682 } 1682 }
1683 memset(part, 0, MBR_PART_COUNT * sizeof *part); 1683 memset(part, 0, MBR_PART_COUNT * sizeof *part);
1684#ifdef BOOTSEL 1684#ifdef BOOTSEL
1685 memset(&mbri->mbrb, 0, sizeof mbri->mbrb); 1685 memset(&mbri->mbrb, 0, sizeof mbri->mbrb);
1686#endif 1686#endif
 1687
 1688 /*
 1689 * We may have changed alignment settings due to partitions
 1690 * ending on an MB boundary - undo that, now that the partitions
 1691 * are gone.
 1692 */
 1693 mbr_change_disk_geom(arg, myparts->geo_cyl, myparts->geo_head,
 1694 myparts->geo_sec);
 1695
1687 return true; 1696 return true;
1688} 1697}
1689 1698
1690/* 1699/*
1691 * helper function to fix up mbrp_start and mbrp_size for the 1700 * helper function to fix up mbrp_start and mbrp_size for the
1692 * extended MBRs "partition b" entries after addition/deletion 1701 * extended MBRs "partition b" entries after addition/deletion
1693 * of some partition. 1702 * of some partition.
1694 */ 1703 */
1695static void 1704static void
1696mbr_fixup_ext_chain(mbr_info_t *primary, uint ext_start, uint ext_end) 1705mbr_fixup_ext_chain(mbr_info_t *primary, uint ext_start, uint ext_end)
1697{ 1706{
1698 for (mbr_info_t *m = primary->extended; m != NULL; m = m->extended) { 1707 for (mbr_info_t *m = primary->extended; m != NULL; m = m->extended) {
1699 if (m->extended == NULL) { 1708 if (m->extended == NULL) {