Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst x86: fix previous: in the UEFI case copy th...
details: https://anonhg.NetBSD.org/src/rev/43a21548e842
branches: trunk
changeset: 361113:43a21548e842
user: martin <martin%NetBSD.org@localhost>
date: Thu Feb 10 16:11:41 2022 +0000
description:
x86: fix previous: in the UEFI case copy the bootloaders from install
media during initial installation, but use the (by then: updated)
files from the target disk for system upgrades.
diffstat:
usr.sbin/sysinst/arch/i386/md.c | 29 +++++++++++++++++++----------
usr.sbin/sysinst/defs.h | 3 ++-
usr.sbin/sysinst/target.c | 31 +++++++++++++++++++++++++++++--
3 files changed, 50 insertions(+), 13 deletions(-)
diffs (162 lines):
diff -r 03276b268fbe -r 43a21548e842 usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c Thu Feb 10 13:05:07 2022 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c Thu Feb 10 16:11:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.34 2022/01/29 16:01:18 martin Exp $ */
+/* $NetBSD: md.c,v 1.35 2022/02/10 16:11:42 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -334,9 +334,10 @@
* boot partition (or update them).
*/
static int
-copy_uefi_boot(const struct part_usage_info *boot)
+copy_uefi_boot(const struct part_usage_info *boot, bool target_is_populated)
{
char dev[MAXPATHLEN], path[MAXPATHLEN], src[MAXPATHLEN];
+ const char *s;
size_t i;
int err;
@@ -364,13 +365,18 @@
make_target_dir(path);
for (i = 0; i < __arraycount(uefi_bootloaders); i++) {
- strcpy(src, target_expand(uefi_bootloaders[i]));
+ s = uefi_bootloaders[i];
+ strcpy(src, target_is_populated ? target_expand(s) : s);
if (access(src, R_OK) != 0)
continue;
- err = cp_within_target(uefi_bootloaders[i], path, 0);
+ err = target_is_populated ?
+ cp_within_target(s, path, 0) :
+ cp_to_target(s, path);
if (err)
return err;
}
+ if (boot->mount[0] == 0)
+ target_unmount("/mnt");
return 0;
}
@@ -379,7 +385,8 @@
* Find (U)EFI boot partition and install/update bootloaders
*/
static int
-update_uefi_boot_code(struct install_partition_desc *install)
+update_uefi_boot_code(struct install_partition_desc *install,
+ bool target_is_populated)
{
size_t i, boot_part;
@@ -405,7 +412,8 @@
}
if (boot_part < install->num)
- return copy_uefi_boot(&install->infos[boot_part]);
+ return copy_uefi_boot(&install->infos[boot_part],
+ target_is_populated);
return -1; /* no EFI boot partition found */
}
@@ -420,17 +428,18 @@
}
static int
-update_boot_code(struct install_partition_desc *install)
+update_boot_code(struct install_partition_desc *install,
+ bool target_is_populated)
{
return uefi_boot ?
- update_uefi_boot_code(install)
+ update_uefi_boot_code(install, target_is_populated)
: update_bios_boot_code(install);
}
static int
md_post_newfs_uefi(struct install_partition_desc *install)
{
- return update_uefi_boot_code(install);
+ return update_uefi_boot_code(install, false);
}
/*
@@ -450,7 +459,7 @@
md_post_extract(struct install_partition_desc *install, bool upgrade)
{
if (upgrade)
- update_boot_code(install);
+ update_boot_code(install, true);
#if defined(__amd64__)
if (get_kernel_set() == SET_KERNEL_2) {
diff -r 03276b268fbe -r 43a21548e842 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h Thu Feb 10 13:05:07 2022 +0000
+++ b/usr.sbin/sysinst/defs.h Thu Feb 10 16:11:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.79 2022/01/30 11:58:29 martin Exp $ */
+/* $NetBSD: defs.h,v 1.80 2022/02/10 16:11:41 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -922,6 +922,7 @@
void mv_within_target_or_die(const char *, const char *);
int cp_within_target(const char *, const char *, int);
int target_mount(const char *, const char *, const char *);
+int target_unmount(const char *);
int target_mount_do(const char *, const char *, const char *);
int target_test(unsigned int, const char *);
int target_dir_exists_p(const char *);
diff -r 03276b268fbe -r 43a21548e842 usr.sbin/sysinst/target.c
--- a/usr.sbin/sysinst/target.c Thu Feb 10 13:05:07 2022 +0000
+++ b/usr.sbin/sysinst/target.c Thu Feb 10 16:11:41 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: target.c,v 1.17 2022/01/30 11:58:29 martin Exp $ */
+/* $NetBSD: target.c,v 1.18 2022/02/10 16:11:41 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.17 2022/01/30 11:58:29 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.18 2022/02/10 16:11:41 martin Exp $");
#endif
/*
@@ -527,6 +527,33 @@
return target_mount_do(opts, from, on);
}
+int
+target_unmount(const char *mount_point)
+{
+ struct unwind_mount *m, *prev = NULL;
+ int error;
+
+ for (m = unwind_mountlist; m != NULL; prev = m, m = m->um_prev)
+ if (strcmp(m->um_mountpoint, mount_point) == 0)
+ break;
+
+ if (m == NULL)
+ return ENOTDIR;
+
+ error = run_program(0, "/sbin/umount %s%s",
+ target_prefix(), m->um_mountpoint);
+ if (error)
+ return error;
+
+ if (m == unwind_mountlist)
+ unwind_mountlist = m->um_prev;
+ else
+ prev->um_prev = m->um_prev;
+ free(m);
+
+ return 0;
+}
+
static bool
delete_wedge(const char *disk, const char *wedge)
{
Home |
Main Index |
Thread Index |
Old Index