diff options
| author | msaitoh <msaitoh@NetBSD.org> | 2022-02-14 06:45:34 +0000 |
|---|---|---|
| committer | msaitoh <msaitoh@NetBSD.org> | 2022-02-14 06:45:34 +0000 |
| commit | 904c472de7b95464b5019dd23bc64f6cee284573 (patch) | |
| tree | b8fecc5c697577042274990c6009c686a09b1637 /usr.sbin | |
| parent | 3388e6971258c1d3052650f65deb0535fc395f44 (diff) | |
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.
Diffstat (limited to 'usr.sbin')
| -rw-r--r-- | usr.sbin/sysinst/arch/i386/md.c | 29 | ||||
| -rw-r--r-- | usr.sbin/sysinst/defs.h | 3 | ||||
| -rw-r--r-- | usr.sbin/sysinst/target.c | 31 |
3 files changed, 50 insertions, 13 deletions
diff --git a/usr.sbin/sysinst/arch/i386/md.c b/usr.sbin/sysinst/arch/i386/md.c index 8c2961276fe..67393eddb68 100644 --- a/usr.sbin/sysinst/arch/i386/md.c +++ b/usr.sbin/sysinst/arch/i386/md.c @@ -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_partition_desc *install) * 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_info *boot) 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_info *boot) * 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_partition_desc *install) } 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_partition_desc *install) } 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) { diff --git a/usr.sbin/sysinst/defs.h b/usr.sbin/sysinst/defs.h index 5ac94d91392..d8d0a405c09 100644 --- a/usr.sbin/sysinst/defs.h +++ b/usr.sbin/sysinst/defs.h @@ -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 *); diff --git a/usr.sbin/sysinst/target.c b/usr.sbin/sysinst/target.c index 8608c9d133d..e82ee51161c 100644 --- a/usr.sbin/sysinst/target.c +++ b/usr.sbin/sysinst/target.c @@ -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 char *from, const char *on) 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) { |
