Module Name: src Committed By: msaitoh Date: Mon Feb 14 06:45:34 UTC 2022
Modified Files: src/usr.sbin/sysinst [netbsd-9]: defs.h target.c src/usr.sbin/sysinst/arch/i386 [netbsd-9]: md.c Log Message: Pull up following revision(s) (requested by martin in ticket #1427): usr.sbin/sysinst/defs.h: revision 1.80 usr.sbin/sysinst/target.c: revision 1.18 usr.sbin/sysinst/arch/i386/md.c: revision 1.35 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. To generate a diff of this commit: cvs rdiff -u -r1.42.2.10 -r1.42.2.11 src/usr.sbin/sysinst/defs.h cvs rdiff -u -r1.8.2.6 -r1.8.2.7 src/usr.sbin/sysinst/target.c cvs rdiff -u -r1.20.2.9 -r1.20.2.10 src/usr.sbin/sysinst/arch/i386/md.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/defs.h diff -u src/usr.sbin/sysinst/defs.h:1.42.2.10 src/usr.sbin/sysinst/defs.h:1.42.2.11 --- src/usr.sbin/sysinst/defs.h:1.42.2.10 Wed Feb 2 04:25:36 2022 +++ src/usr.sbin/sysinst/defs.h Mon Feb 14 06:45:34 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.42.2.10 2022/02/02 04:25:36 msaitoh Exp $ */ +/* $NetBSD: defs.h,v 1.42.2.11 2022/02/14 06:45:34 msaitoh Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -899,6 +899,7 @@ void dup_file_into_target(const char *); 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 *); Index: src/usr.sbin/sysinst/target.c diff -u src/usr.sbin/sysinst/target.c:1.8.2.6 src/usr.sbin/sysinst/target.c:1.8.2.7 --- src/usr.sbin/sysinst/target.c:1.8.2.6 Wed Feb 2 04:25:36 2022 +++ src/usr.sbin/sysinst/target.c Mon Feb 14 06:45:34 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: target.c,v 1.8.2.6 2022/02/02 04:25:36 msaitoh Exp $ */ +/* $NetBSD: target.c,v 1.8.2.7 2022/02/14 06:45:34 msaitoh 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.8.2.6 2022/02/02 04:25:36 msaitoh Exp $"); +__RCSID("$NetBSD: target.c,v 1.8.2.7 2022/02/14 06:45:34 msaitoh Exp $"); #endif /* @@ -527,6 +527,33 @@ target_mount(const char *opts, const cha 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) { Index: src/usr.sbin/sysinst/arch/i386/md.c diff -u src/usr.sbin/sysinst/arch/i386/md.c:1.20.2.9 src/usr.sbin/sysinst/arch/i386/md.c:1.20.2.10 --- src/usr.sbin/sysinst/arch/i386/md.c:1.20.2.9 Wed Feb 2 04:25:37 2022 +++ src/usr.sbin/sysinst/arch/i386/md.c Mon Feb 14 06:45:34 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.20.2.9 2022/02/02 04:25:37 msaitoh Exp $ */ +/* $NetBSD: md.c,v 1.20.2.10 2022/02/14 06:45:34 msaitoh Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -334,9 +334,10 @@ md_post_newfs_bios(struct install_partit * 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 @@ copy_uefi_boot(const struct part_usage_i 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 @@ copy_uefi_boot(const struct part_usage_i * 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 @@ update_uefi_boot_code(struct install_par } 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 @@ update_bios_boot_code(struct install_par } 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 @@ int 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) {