Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/usr.sbin/sysinst Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/1008b8c4c867
branches:  netbsd-9
changeset: 361561:1008b8c4c867
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Feb 14 06:45:34 2022 +0000

description:
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:

 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 ed800f74d68a -r 1008b8c4c867 usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c   Tue Feb 08 14:45:57 2022 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c   Mon Feb 14 06:45:34 2022 +0000
@@ -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 @@
  * 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 ed800f74d68a -r 1008b8c4c867 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Feb 08 14:45:57 2022 +0000
+++ b/usr.sbin/sysinst/defs.h   Mon Feb 14 06:45:34 2022 +0000
@@ -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   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 ed800f74d68a -r 1008b8c4c867 usr.sbin/sysinst/target.c
--- a/usr.sbin/sysinst/target.c Tue Feb 08 14:45:57 2022 +0000
+++ b/usr.sbin/sysinst/target.c Mon Feb 14 06:45:34 2022 +0000
@@ -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 @@
        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