Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Preparations to make the extended partition...



details:   https://anonhg.NetBSD.org/src/rev/f75227b181f6
branches:  trunk
changeset: 368414:f75227b181f6
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jul 10 10:52:40 2022 +0000

description:
Preparations to make the extended partitioning during normal installation
more usefull - pass an optional install_description to partman().

diffstat:

 usr.sbin/sysinst/defs.h    |  12 ++++++--
 usr.sbin/sysinst/install.c |   4 +-
 usr.sbin/sysinst/main.c    |   4 +-
 usr.sbin/sysinst/menus.mi  |   4 +-
 usr.sbin/sysinst/partman.c |  63 +++++++++++++++++++++++++++++----------------
 usr.sbin/sysinst/util.c    |  43 ++++++++++++++++++++++++++++++-
 6 files changed, 98 insertions(+), 32 deletions(-)

diffs (truncated from 313 to 300 lines):

diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/defs.h   Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.85 2022/06/24 22:28:11 tsutsui Exp $        */
+/*     $NetBSD: defs.h,v 1.86 2022/07/10 10:52:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -503,6 +503,7 @@
        part_id id;
        struct disk_partitions *parts;
        void *dev_ptr;
+       struct install_partition_desc *install;
        size_t index;   /* e.g. if PM_RAID: this is raids[index] */
        int dev_ptr_delta;
        char fullname[SSTRSIZE];
@@ -895,6 +896,11 @@
 const char *set_postfix(const char*);
 bool   usage_set_from_parts(struct partition_usage_set*,
            struct disk_partitions*);
+bool   usage_set_from_install_desc(struct partition_usage_set*,
+           const struct install_partition_desc*,
+           struct disk_partitions*);
+bool   merge_usage_set_into_install_desc(struct install_partition_desc*,
+           const struct partition_usage_set*);
 void   free_usage_set(struct partition_usage_set*);
 bool   install_desc_from_parts(struct install_partition_desc *,
            struct disk_partitions*);
@@ -938,12 +944,12 @@
 
 /* from partman.c */
 #ifndef NO_PARTMAN
-int partman(void);
+int partman(struct install_partition_desc*);
 int pm_getrefdev(struct pm_devs *);
 void update_wedges(const char *);
 void pm_destroy_all(void);
 #else
-static inline int partman(void) { return -1; }
+static inline int partman(struct install_partition_desc*) { return -1; }
 static inline int pm_getrefdev(struct pm_devs *x __unused) { return -1; }
 #define update_wedges(x) __nothing
 #endif
diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/install.c
--- a/usr.sbin/sysinst/install.c        Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/install.c        Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: install.c,v 1.23 2022/04/21 17:30:15 martin Exp $      */
+/*     $NetBSD: install.c,v 1.24 2022/07/10 10:52:40 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -173,7 +173,7 @@
        /* Create and mount partitions */
        find_disks_ret = find_disks(msg_string(MSG_install), false);
        if (partman_go == 1) {
-               if (partman() < 0) {
+               if (partman(&install) < 0) {
                        hit_enter_to_continue(MSG_abort_part, NULL);
                        return;
                }
diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/main.c
--- a/usr.sbin/sysinst/main.c   Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/main.c   Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.29 2022/01/28 19:38:51 wiz Exp $    */
+/*     $NetBSD: main.c,v 1.30 2022/07/10 10:52:40 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -307,7 +307,7 @@
 
        /* Menu processing */
        if (partman_go)
-               partman();
+               partman(NULL);
        else
                process_menu(MENU_netbsd, NULL);
 
diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/menus.mi
--- a/usr.sbin/sysinst/menus.mi Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/menus.mi Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menus.mi,v 1.25 2022/05/18 16:39:03 martin Exp $       */
+/*     $NetBSD: menus.mi,v 1.26 2022/07/10 10:52:40 martin Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -283,7 +283,7 @@
                action {
 #ifndef NO_PARTMAN
                        partman_go = 1;
-                       partman();
+                       partman(NULL);
 #endif
                };
        option MSG_Logging_functions, action { do_logging(); };
diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/partman.c        Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partman.c,v 1.55 2022/04/08 10:17:55 andvar Exp $ */
+/*     $NetBSD: partman.c,v 1.56 2022/07/10 10:52:41 martin Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -241,9 +241,16 @@
 static int pm_raid_disk_del(menudesc *, void *);
 static int pm_cgd_disk_set(struct cgd_desc *, struct part_entry *);
 static int pm_mount(struct pm_devs *, int);
-static int pm_upddevlist(menudesc *, void *);
+static int pm_upddevlist(menudesc *, void *, struct install_partition_desc *);
 static void pm_select(struct pm_devs *);
 
+
+static int
+pm_do_upddevlist(menudesc *m, void *arg)
+{
+       return pm_upddevlist(m, arg, ((struct part_entry*)arg)->install);
+}
+
 static void
 pm_edit_size_value(msg prompt_msg, daddr_t bps, daddr_t cylsec, daddr_t *size)
 {
@@ -2706,7 +2713,7 @@
                return -1;
        }
        if (m != NULL && arg != NULL)
-               pm_upddevlist(m, arg);
+               pm_do_upddevlist(m, arg);
        if (logfp)
                fflush (logfp);
 
@@ -2947,7 +2954,7 @@
 
 /* Update partman main menu with devices list */
 static int
-pm_upddevlist(menudesc *m, void *arg)
+pm_upddevlist(menudesc *m, void *arg, struct install_partition_desc *install)
 {
        int i = 0;
        size_t ii;
@@ -2980,17 +2987,19 @@
                return -1;
 
        SLIST_FOREACH(pm_i, &pm_head, l) {
+               struct part_entry *cur_entry = ((struct part_entry *)arg)+i;
                memset(&m->opts[i], 0, sizeof m->opts[i]);
                m->opts[i].opt_action = pm_submenu;
-               ((struct part_entry *)arg)[i].dev_ptr = pm_i;
-               ((struct part_entry *)arg)[i].id = NO_PART;
+               cur_entry->dev_ptr = pm_i;
+               cur_entry->id = NO_PART;
+               cur_entry->install = install;
                if (pm_i->no_part)
-                       ((struct part_entry *)arg)[i].type = PM_SPEC;
+                       cur_entry->type = PM_SPEC;
                else {
                        ps = pm_i->parts != NULL ? pm_i->parts->pscheme : NULL;
                        secondary = NULL;
 
-                       ((struct part_entry *)arg)[i].type = PM_DISK;
+                       cur_entry->type = PM_DISK;
 
                        for (ii = 0; pm_i->parts != NULL &&
                            ii < pm_i->parts->num_part; ii++) {
@@ -3014,13 +3023,14 @@
                                if (i >= MAX_ENTRIES)
                                        break;
                                i++;
+                               cur_entry = ((struct part_entry *)arg)+i;
                                memset(&m->opts[i], 0, sizeof m->opts[i]);
                                m->opts[i].opt_action = pm_submenu;
-                               ((struct part_entry *)arg)[i].parts =
-                                   pm_i->parts;
-                               ((struct part_entry *)arg)[i].dev_ptr = pm_i;
-                               ((struct part_entry *)arg)[i].id = ii;
-                               ((struct part_entry *)arg)[i].type = PM_PART;
+                               cur_entry->parts = pm_i->parts;
+                               cur_entry->dev_ptr = pm_i;
+                               cur_entry->install = install;
+                               cur_entry->id = ii;
+                               cur_entry->type = PM_PART;
                        }
 
                        for (ii = 0; secondary != NULL &&
@@ -3036,12 +3046,14 @@
                                if (i >= MAX_ENTRIES)
                                        break;
                                i++;
+                               cur_entry = ((struct part_entry *)arg)+i;
                                memset(&m->opts[i], 0, sizeof m->opts[i]);
                                m->opts[i].opt_action = pm_submenu;
-                               ((struct part_entry *)arg)[i].parts = secondary;
-                               ((struct part_entry *)arg)[i].dev_ptr = pm_i;
-                               ((struct part_entry *)arg)[i].id = ii;
-                               ((struct part_entry *)arg)[i].type = PM_PART;
+                               cur_entry->parts = secondary;
+                               cur_entry->dev_ptr = pm_i;
+                               cur_entry->install = install;
+                               cur_entry->id = ii;
+                               cur_entry->type = PM_PART;
                        }
                }
                i++;
@@ -3072,7 +3084,7 @@
 
        m->opts[i++] = (struct menu_ent) {
                .opt_name = MSG_updpmlist,
-               .opt_action = pm_upddevlist,
+               .opt_action = pm_do_upddevlist,
        };
        m->opts[i  ] = (struct menu_ent) {
                .opt_name = MSG_savepm,
@@ -3103,12 +3115,12 @@
 
 /* Main partman function */
 int
-partman(void)
+partman(struct install_partition_desc *install)
 {
        int menu_no, menu_num_entries;
        static int firstrun = 1;
        menu_ent menu_entries[MAX_ENTRIES+6];
-       struct part_entry args[MAX_ENTRIES];
+       struct part_entry args[MAX_ENTRIES] = { 0 };
 
        if (firstrun) {
                check_available_binaries();
@@ -3181,7 +3193,8 @@
        }
 
        do {
-               menu_num_entries = pm_upddevlist(&(menudesc){.opts = menu_entries}, args);
+               menu_num_entries = pm_upddevlist(&(menudesc){.opts = menu_entries},
+                   args, install);
                menu_no = new_menu(MSG_partman_header,
                        menu_entries, menu_num_entries+1, 1, 1, 0, 75, /* Fixed width */
                        MC_ALWAYS_SCROLL | MC_NOBOX | MC_NOCLEAR,
@@ -3270,8 +3283,14 @@
        }
 
        if (parts != NULL) {
-               usage_set_from_parts(&pset, parts);
+               if (!pe->install ||
+                   !usage_set_from_install_desc(&pset, pe->install, parts))
+                       usage_set_from_parts(&pset, parts);
                edit_and_check_label(my_pm, &pset, false);
+
+               if (pe->install)
+                       merge_usage_set_into_install_desc(pe->install,
+                           &pset);
                free_usage_set(&pset);
        }
 
diff -r 5ae2726ed237 -r f75227b181f6 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Sun Jul 10 09:59:22 2022 +0000
+++ b/usr.sbin/sysinst/util.c   Sun Jul 10 10:52:40 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.68 2022/06/24 22:05:24 tsutsui Exp $        */
+/*     $NetBSD: util.c,v 1.69 2022/07/10 10:52:41 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -2468,6 +2468,47 @@
        return usage_info_list_from_parts(&wanted->infos, &wanted->num, parts);
 }
 
+bool
+usage_set_from_install_desc(struct partition_usage_set *pset,
+    const struct install_partition_desc *install,
+    struct disk_partitions *parts)
+{
+       size_t cnt, i;
+
+       memset(pset, 0, sizeof(*pset));
+       pset->parts = parts;
+
+       if (!install->infos || !install->num)
+               return false;
+
+       for (cnt = 0, i = 0; i < install->num; i++) {
+               if (install->infos[i].parts != parts)
+                       continue;
+               cnt++;
+       }
+       if (!cnt)
+               return false;
+       pset->num = cnt;
+       pset->infos = calloc(cnt, sizeof(*pset->infos));
+       if (!pset->infos)
+               return false;
+       for (cnt = 0, i = 0; i < install->num; i++) {
+               if (install->infos[i].parts != parts)
+                       continue;
+               pset->infos[cnt] = install->infos[i];
+               cnt++;
+       }
+       return true;



Home | Main Index | Thread Index | Old Index