Sun Jul 14 11:26:18 2019 UTC ()
Don't force mounting of newfs'd partitions.
Provide MD hooks for setups where we do not need any bootblocks.


(martin)
diff -r1.19 -r1.20 src/usr.sbin/sysinst/bsddisklabel.c

cvs diff -r1.19 -r1.20 src/usr.sbin/sysinst/bsddisklabel.c (expand / switch to unified diff)

--- src/usr.sbin/sysinst/bsddisklabel.c 2019/07/12 18:28:08 1.19
+++ src/usr.sbin/sysinst/bsddisklabel.c 2019/07/14 11:26:18 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bsddisklabel.c,v 1.19 2019/07/12 18:28:08 martin Exp $ */ 1/* $NetBSD: bsddisklabel.c,v 1.20 2019/07/14 11:26:18 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 * Based on code written by Philip A. Nelson for Piermont Information 7 * Based on code written by Philip A. Nelson for Piermont Information
8 * Systems Inc. 8 * Systems Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -1365,28 +1365,26 @@ apply_settings_to_partitions(struct pm_d @@ -1365,28 +1365,26 @@ apply_settings_to_partitions(struct pm_d
1365 outer_align, from, -1); 1365 outer_align, from, -1);
1366 1366
1367 if (cnt == 0) /* no free space for this partition */ 1367 if (cnt == 0) /* no free space for this partition */
1368 continue; 1368 continue;
1369 1369
1370 infos[i].start = space.start; 1370 infos[i].start = space.start;
1371 infos[i].size = min(want->size, space.size); 1371 infos[i].size = min(want->size, space.size);
1372 infos[i].nat_type = 1372 infos[i].nat_type =
1373 ps->pscheme->get_fs_part_type( 1373 ps->pscheme->get_fs_part_type(
1374 want->fs_type, want->fs_version); 1374 want->fs_type, want->fs_version);
1375 infos[i].last_mounted = want->mount; 1375 infos[i].last_mounted = want->mount;
1376 infos[i].fs_type = want->fs_type; 1376 infos[i].fs_type = want->fs_type;
1377 infos[i].fs_sub_type = want->fs_version; 1377 infos[i].fs_sub_type = want->fs_version;
1378 if (want->fs_type != FS_UNUSED && want->type != PT_swap) 
1379 want->instflags |= PUIINST_NEWFS|PUIINST_MOUNT; 
1380 new_part_id = ps->pscheme->add_partition(ps, 1378 new_part_id = ps->pscheme->add_partition(ps,
1381 &infos[i], NULL); 1379 &infos[i], NULL);
1382 if (new_part_id == NO_PART) 1380 if (new_part_id == NO_PART)
1383 continue; /* failed to add, skip */ 1381 continue; /* failed to add, skip */
1384 1382
1385 ps->pscheme->get_part_info(ps, 1383 ps->pscheme->get_part_info(ps,
1386 new_part_id, &infos[i]); 1384 new_part_id, &infos[i]);
1387 want->cur_part_id = new_part_id; 1385 want->cur_part_id = new_part_id;
1388 1386
1389 want->flags |= PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER; 1387 want->flags |= PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER;
1390 from = rounddown(infos[i].start +  1388 from = rounddown(infos[i].start +
1391 infos[i].size+outer_align, outer_align); 1389 infos[i].size+outer_align, outer_align);
1392 } 1390 }
@@ -1410,28 +1408,31 @@ apply_settings_to_partitions(struct pm_d @@ -1410,28 +1408,31 @@ apply_settings_to_partitions(struct pm_d
1410 -1); 1408 -1);
1411 1409
1412 if (cnt == 0) 1410 if (cnt == 0)
1413 continue; /* no free space for this partition */ 1411 continue; /* no free space for this partition */
1414 1412
1415 infos[i].start = space.start; 1413 infos[i].start = space.start;
1416 infos[i].size = min(want->size, space.size); 1414 infos[i].size = min(want->size, space.size);
1417 infos[i].nat_type = 1415 infos[i].nat_type =
1418 wanted->parts->pscheme->get_fs_part_type(want->fs_type, 1416 wanted->parts->pscheme->get_fs_part_type(want->fs_type,
1419 want->fs_version); 1417 want->fs_version);
1420 infos[i].last_mounted = want->mount; 1418 infos[i].last_mounted = want->mount;
1421 infos[i].fs_type = want->fs_type; 1419 infos[i].fs_type = want->fs_type;
1422 infos[i].fs_sub_type = want->fs_version; 1420 infos[i].fs_sub_type = want->fs_version;
1423 if (want->fs_type != FS_UNUSED && want->type != PT_swap) 1421 if (want->fs_type != FS_UNUSED && want->type != PT_swap) {
1424 want->instflags |= PUIINST_NEWFS|PUIINST_MOUNT; 1422 want->instflags |= PUIINST_NEWFS;
 1423 if (want->mount[0] != 0)
 1424 want->instflags |= PUIINST_MOUNT;
 1425 }
1425 new_part_id = wanted->parts->pscheme->add_partition( 1426 new_part_id = wanted->parts->pscheme->add_partition(
1426 wanted->parts, &infos[i], NULL); 1427 wanted->parts, &infos[i], NULL);
1427 if (new_part_id == NO_PART) 1428 if (new_part_id == NO_PART)
1428 continue; /* failed to add, skip */ 1429 continue; /* failed to add, skip */
1429 1430
1430 wanted->parts->pscheme->get_part_info( 1431 wanted->parts->pscheme->get_part_info(
1431 wanted->parts, new_part_id, &infos[i]); 1432 wanted->parts, new_part_id, &infos[i]);
1432 from = rounddown(infos[i].start+infos[i].size+align, align); 1433 from = rounddown(infos[i].start+infos[i].size+align, align);
1433 } 1434 }
1434 1435
1435 1436
1436 /* 1437 /*
1437 * If there are any outer partitions that we need as inner ones 1438 * If there are any outer partitions that we need as inner ones
@@ -1448,29 +1449,26 @@ apply_settings_to_partitions(struct pm_d @@ -1448,29 +1449,26 @@ apply_settings_to_partitions(struct pm_d
1448 continue; 1449 continue;
1449 1450
1450 if ((want->flags & (PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER)) != 1451 if ((want->flags & (PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER)) !=
1451 (PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER)) 1452 (PUIFLAG_ADD_INNER|PUIFLG_IS_OUTER))
1452 continue; 1453 continue;
1453 1454
1454 infos[i].start = want->cur_start; 1455 infos[i].start = want->cur_start;
1455 infos[i].size = want->size; 1456 infos[i].size = want->size;
1456 infos[i].nat_type = wanted->parts->pscheme->get_fs_part_type( 1457 infos[i].nat_type = wanted->parts->pscheme->get_fs_part_type(
1457 want->fs_type, want->fs_version); 1458 want->fs_type, want->fs_version);
1458 infos[i].last_mounted = want->mount; 1459 infos[i].last_mounted = want->mount;
1459 infos[i].fs_type = want->fs_type; 1460 infos[i].fs_type = want->fs_type;
1460 infos[i].fs_sub_type = want->fs_version; 1461 infos[i].fs_sub_type = want->fs_version;
1461 if (want->fs_type != FS_UNUSED && 
1462 want->type != PT_swap) 
1463 want->instflags |= PUIINST_NEWFS|PUIINST_MOUNT; 
1464 1462
1465 if (wanted->parts->pscheme->add_outer_partition 1463 if (wanted->parts->pscheme->add_outer_partition
1466 != NULL) 1464 != NULL)
1467 new_part_id = wanted->parts->pscheme-> 1465 new_part_id = wanted->parts->pscheme->
1468 add_outer_partition( 1466 add_outer_partition(
1469 wanted->parts, &infos[i], NULL); 1467 wanted->parts, &infos[i], NULL);
1470 else 1468 else
1471 new_part_id = wanted->parts->pscheme-> 1469 new_part_id = wanted->parts->pscheme->
1472 add_partition( 1470 add_partition(
1473 wanted->parts, &infos[i], NULL); 1471 wanted->parts, &infos[i], NULL);
1474  1472
1475 if (new_part_id == NO_PART) 1473 if (new_part_id == NO_PART)
1476 continue; /* failed to add, skip */ 1474 continue; /* failed to add, skip */
@@ -1653,57 +1651,65 @@ make_bsd_partitions(struct install_parti @@ -1653,57 +1651,65 @@ make_bsd_partitions(struct install_parti
1653 /* and check them */ 1651 /* and check them */
1654 if (check_partitions(install)) 1652 if (check_partitions(install))
1655 break; 1653 break;
1656 } 1654 }
1657 1655
1658 /* we moved infos from wanted to install target */ 1656 /* we moved infos from wanted to install target */
1659 wanted.infos = NULL; 1657 wanted.infos = NULL;
1660 free_usage_set(&wanted); 1658 free_usage_set(&wanted);
1661 1659
1662 /* Everything looks OK. */ 1660 /* Everything looks OK. */
1663 return true; 1661 return true;
1664} 1662}
1665 1663
 1664#ifndef MD_NEED_BOOTBLOCK
 1665#define MD_NEED_BOOTBLOCK(A) true
 1666#endif
 1667
1666/* 1668/*
1667 * check that there is at least a / somewhere. 1669 * check that there is at least a / somewhere.
1668 */ 1670 */
1669bool 1671bool
1670check_partitions(struct install_partition_desc *install) 1672check_partitions(struct install_partition_desc *install)
1671{ 1673{
1672#ifdef HAVE_BOOTXX_xFS 1674#ifdef HAVE_BOOTXX_xFS
1673 int rv = 1; 1675 int rv = 1;
1674 char *bootxx; 1676 char *bootxx;
1675#endif 1677#endif
1676#ifndef HAVE_UFS2_BOOT 1678#ifndef HAVE_UFS2_BOOT
1677 size_t i; 1679 size_t i;
1678#endif 1680#endif
1679 1681
1680#ifdef HAVE_BOOTXX_xFS 1682#ifdef HAVE_BOOTXX_xFS
1681 /* check if we have boot code for the root partition type */ 1683 if (MD_NEED_BOOTBLOCK(install)) {
1682 bootxx = bootxx_name(install); 1684 /* check if we have boot code for the root partition type */
1683 if (bootxx != NULL) { 1685 bootxx = bootxx_name(install);
1684 rv = access(bootxx, R_OK); 1686 if (bootxx != NULL) {
1685 free(bootxx); 1687 rv = access(bootxx, R_OK);
1686 } else 1688 free(bootxx);
1687 rv = -1; 1689 } else
1688 if (rv != 0) { 1690 rv = -1;
1689 hit_enter_to_continue(NULL, MSG_No_Bootcode); 1691 if (rv != 0) {
1690 return false; 1692 hit_enter_to_continue(NULL, MSG_No_Bootcode);
 1693 return false;
 1694 }
1691 } 1695 }
1692#endif 1696#endif
1693#ifndef HAVE_UFS2_BOOT 1697#ifndef HAVE_UFS2_BOOT
1694 for (i = 0; i < install->num; i++) { 1698 if (MD_NEED_BOOTBLOCK(install)) {
1695 if (install->infos[i].type != PT_root) 1699 for (i = 0; i < install->num; i++) {
1696 continue; 1700 if (install->infos[i].type != PT_root)
1697 if (strcmp(install->infos[i].mount, "/") != 0) 1701 continue;
1698 continue; 1702 if (strcmp(install->infos[i].mount, "/") != 0)
1699 if (install->infos[i].fs_type != FS_BSDFFS) 1703 continue;
1700 continue; 1704 if (install->infos[i].fs_type != FS_BSDFFS)
1701 if (install->infos[i].fs_version != 2) 1705 continue;
1702 continue; 1706 if (install->infos[i].fs_version != 2)
1703 hit_enter_to_continue(NULL, MSG_cannot_ufs2_root); 1707 continue;
1704 return false; 1708 hit_enter_to_continue(NULL, MSG_cannot_ufs2_root);
 1709 return false;
 1710 }
1705 } 1711 }
1706#endif 1712#endif
1707 1713
1708 return md_check_partitions(install); 1714 return md_check_partitions(install);
1709} 1715}