Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst For upgrade / re-install allow the currentl...



details:   https://anonhg.NetBSD.org/src/rev/9812a3c97a0f
branches:  trunk
changeset: 457877:9812a3c97a0f
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 23 18:13:40 2019 +0000

description:
For upgrade / re-install allow the currently running system as a target
in the "disk" selection.

diffstat:

 usr.sbin/sysinst/configmenu.c |   4 +-
 usr.sbin/sysinst/defs.h       |  11 ++++++-
 usr.sbin/sysinst/disks.c      |  63 ++++++++++++++++++++++++++++++++++++------
 usr.sbin/sysinst/install.c    |   6 ++--
 usr.sbin/sysinst/msg.mi.de    |   4 ++-
 usr.sbin/sysinst/msg.mi.en    |   5 ++-
 usr.sbin/sysinst/msg.mi.es    |   5 ++-
 usr.sbin/sysinst/msg.mi.fr    |   5 ++-
 usr.sbin/sysinst/msg.mi.pl    |   5 ++-
 usr.sbin/sysinst/partman.c    |   4 +-
 usr.sbin/sysinst/target.c     |   7 +++-
 usr.sbin/sysinst/upgrade.c    |  40 ++++++++++++++++----------
 12 files changed, 118 insertions(+), 41 deletions(-)

diffs (truncated from 426 to 300 lines):

diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/configmenu.c
--- a/usr.sbin/sysinst/configmenu.c     Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/configmenu.c     Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.9 2019/06/22 20:46:07 christos Exp $ */
+/* $NetBSD: configmenu.c,v 1.10 2019/07/23 18:13:40 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -446,7 +446,7 @@
        /* if the target isn't mounted already, figure it out. */
        if (install != NULL && target_mounted() == 0) {
                partman_go = 0;
-               if (find_disks(msg_string(MSG_configure_prior)) < 0)
+               if (find_disks(msg_string(MSG_configure_prior), true) < 0)
                        return;
 
                if (mount_disks(install) != 0)
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/defs.h   Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.40 2019/07/23 16:02:32 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.41 2019/07/23 18:13:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -324,6 +324,7 @@
 struct install_partition_desc {
        size_t num;                             /* how many entries in infos */
        struct part_usage_info *infos;          /* individual partitions */
+       bool cur_system;                        /* target is the life system */
 };
 
 /* variables */
@@ -384,6 +385,12 @@
         */
        bool no_part;
 
+       /*
+        * This is a pseudo-device representing the currently running
+        * system (i.e. all mounted file systems).
+        */
+       bool cur_system;
+
        /* Actual values for current disk - set by find_disks() or
           md_get_info() */
        int sectorsize, dlcyl, dlhead, dlsec, dlcylsize, current_cylsize;
@@ -592,7 +599,7 @@
 
 /* from disks.c */
 bool   get_default_cdrom(char *, size_t);
-int    find_disks(const char *);
+int    find_disks(const char *, bool);
 bool enumerate_disks(void *state,bool (*func)(void *state, const char *dev));
 bool is_cdrom_device(const char *dev, bool as_target);
 bool is_bootable_device(const char *dev);
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/disks.c  Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.39 2019/07/23 15:23:14 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.40 2019/07/23 18:13:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -761,11 +761,32 @@
        return true;
 }
 
+static struct pm_devs *
+dummy_whole_system_pm(void)
+{
+       static struct pm_devs whole_system = {
+               .diskdev = "/",
+               .no_mbr = true,
+               .no_part = true,
+               .cur_system = true,
+       };
+       static bool init = false;
+
+       if (!init) {
+               strlcpy(whole_system.diskdev_descr,
+                   msg_string(MSG_running_system),
+                   sizeof whole_system.diskdev_descr);
+       }
+
+       return &whole_system;
+}
+
 int
-find_disks(const char *doingwhat)
+find_disks(const char *doingwhat, bool allow_cur_system)
 {
        struct disk_desc disks[MAX_DISKS];
-       menu_ent dsk_menu[__arraycount(disks) + 1]; // + 1 for extended partitioning entry
+       /* need two more menu entries: current system + extended partitioning */
+       menu_ent dsk_menu[__arraycount(disks) + 2];
        struct disk_desc *disk;
        int i = 0, skipped = 0;
        int already_found, numdisks, selected_disk = -1;
@@ -790,16 +811,23 @@
         *                  all disks
         */
        if (partman_go <= 0) {
-               if (numdisks == 0) {
+               if (numdisks == 0 && !allow_cur_system) {
                        /* No disks found! */
                        hit_enter_to_continue(MSG_nodisk, NULL);
                        /*endwin();*/
                        return -1;
                } else {
-                       /* One or more disks found! */
-                       for (i = 0; i < numdisks; i++) {
+                       /* One or more disks found or current system allowed */
+                       i = 0;
+                       if (allow_cur_system) {
+                               dsk_menu[i].opt_name = MSG_running_system;
+                               dsk_menu[i].opt_flags = OPT_EXIT;
+                               dsk_menu[i].opt_action = set_menu_select;
+                               i++;
+                       }
+                       for (; i < numdisks; i++) {
                                dsk_menu[i].opt_name =
-                                   disks[i].dd_descr;
+                                   disks[i-allow_cur_system].dd_descr;
                                dsk_menu[i].opt_flags = OPT_EXIT;
                                dsk_menu[i].opt_action = set_menu_select;
                        }
@@ -807,10 +835,10 @@
                                dsk_menu[i].opt_name = MSG_partman;
                                dsk_menu[i].opt_flags = OPT_EXIT;
                                dsk_menu[i].opt_action = set_menu_select;
+                               i++;
                        }
                        menu_no = new_menu(MSG_Available_disks,
-                               dsk_menu, numdisks
-                                + ((partman_go<0)?1:0), -1,
+                               dsk_menu, i, -1,
                                 4, 0, 0, MC_SCROLL,
                                NULL, NULL, NULL, NULL, NULL);
                        if (menu_no == -1)
@@ -818,6 +846,14 @@
                        msg_fmt_display(MSG_ask_disk, "%s", doingwhat);
                        process_menu(menu_no, &selected_disk);
                        free_menu(menu_no);
+                       if (allow_cur_system) {
+                               if (selected_disk == 0) {
+                                       pm = dummy_whole_system_pm();
+                                       return 1;
+                               } else {
+                                       selected_disk--;
+                               }
+                       }
                }
                if (partman_go < 0 && selected_disk == numdisks) {
                        partman_go = 1;
@@ -1020,6 +1056,9 @@
        struct disk_partitions *parts;
        const char *mnt_opts = NULL, *fsname = NULL;
 
+       if (pm->cur_system)
+               return 1;
+
        if (pm->no_part) {
                /* check if this target device already has a ffs */
                snprintf(rdev, sizeof rdev, _PATH_DEV "/r%s", pm->diskdev);
@@ -1171,6 +1210,9 @@
        const char *dev;
        char dev_buf[PATH_MAX], swap_dev[PATH_MAX];
 
+       if (pm->cur_system)
+               return 1;
+
        swap_dev[0] = 0;
 
        /* Create the fstab. */
@@ -1516,6 +1558,9 @@
        char devdev[PATH_MAX];
        size_t i;
 
+       if (install->cur_system)
+               return 0;
+
        static struct lookfor fstabbuf[] = {
                {"/dev/", "/dev/%s %s ffs %s", "c", NULL, 0, 0, foundffs},
                {"/dev/", "/dev/%s %s ufs %s", "c", NULL, 0, 0, foundffs},
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/install.c
--- a/usr.sbin/sysinst/install.c        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/install.c        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.8 2019/06/20 00:43:55 christos Exp $     */
+/*     $NetBSD: install.c,v 1.9 2019/07/23 18:13:40 martin Exp $       */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -119,7 +119,7 @@
 {
        int find_disks_ret;
        int retcode = 0;
-       struct install_partition_desc install;
+       struct install_partition_desc install = {};
        struct disk_partitions *parts;
 
 #ifndef NO_PARTMAN
@@ -139,7 +139,7 @@
        get_ramsize();
 
        /* Create and mount partitions */
-       find_disks_ret = find_disks(msg_string(MSG_install));
+       find_disks_ret = find_disks(msg_string(MSG_install), false);
        if (partman_go == 1) {
                if (partman() < 0) {
                        hit_enter_to_continue(MSG_abort_part, NULL);
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/msg.mi.de
--- a/usr.sbin/sysinst/msg.mi.de        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.de        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.de,v 1.12 2019/06/12 06:20:18 martin Exp $      */
+/*     $NetBSD: msg.mi.de,v 1.13 2019/07/23 18:13:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1470,3 +1470,5 @@
  *  $0 = file system type              FFSv2
  */
 message size_ptn_not_mounted           {(Sonstige: $0)}
+
+message running_system                 {aktuelles System}
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/msg.mi.en
--- a/usr.sbin/sysinst/msg.mi.en        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.en        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.en,v 1.18 2019/06/21 15:53:16 pgoyette Exp $    */
+/*     $NetBSD: msg.mi.en,v 1.19 2019/07/23 18:13:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1409,3 +1409,6 @@
  *  $0 = file system type              FFSv2
  */
 message size_ptn_not_mounted           {(Other: $0)}
+
+message running_system                 {current system}
+
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/msg.mi.es
--- a/usr.sbin/sysinst/msg.mi.es        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.es        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.es,v 1.13 2019/06/21 15:59:14 pgoyette Exp $    */
+/*     $NetBSD: msg.mi.es,v 1.14 2019/07/23 18:13:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1457,3 +1457,6 @@
  *  $0 = file system type              FFSv2
  */
 message size_ptn_not_mounted           {(Other: $0)}
+
+message running_system                 {current system}
+
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/msg.mi.fr
--- a/usr.sbin/sysinst/msg.mi.fr        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.fr        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.16 2019/06/21 15:59:14 pgoyette Exp $    */
+/*     $NetBSD: msg.mi.fr,v 1.17 2019/07/23 18:13:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1503,3 +1503,6 @@
  *  $0 = file system type              FFSv2
  */
 message size_ptn_not_mounted           {(Other: $0)}
+
+message running_system                 {current system}
+
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/msg.mi.pl
--- a/usr.sbin/sysinst/msg.mi.pl        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/msg.mi.pl        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.pl,v 1.19 2019/07/14 16:04:03 kamil Exp $       */
+/*     $NetBSD: msg.mi.pl,v 1.20 2019/07/23 18:13:40 martin Exp $      */
 /*     Based on english version: */
 /*     NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp       */
 
@@ -1392,3 +1392,6 @@
  *  $0 = file system type              FFSv2
  */
 message size_ptn_not_mounted           {(Inna: $0)}
+
+message running_system                 {current system}
+
diff -r 0e134a82dfc8 -r 9812a3c97a0f usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Tue Jul 23 17:44:03 2019 +0000
+++ b/usr.sbin/sysinst/partman.c        Tue Jul 23 18:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partman.c,v 1.39 2019/07/15 17:17:59 martin Exp $ */
+/*     $NetBSD: partman.c,v 1.40 2019/07/23 18:13:40 martin Exp $ */
 



Home | Main Index | Thread Index | Old Index