Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst If available, show additional names of fore...



details:   https://anonhg.NetBSD.org/src/rev/3a1121e547e5
branches:  trunk
changeset: 458064:3a1121e547e5
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jul 28 16:30:36 2019 +0000

description:
If available, show additional names of foreign partitions in the
size menu. Makes installing on machines with other OSes installed
a lot less confusing.

diffstat:

 usr.sbin/sysinst/bsddisklabel.c |  13 ++++++++++---
 usr.sbin/sysinst/gpt.c          |  23 ++++++++++++++++++++++-
 usr.sbin/sysinst/partitions.h   |   9 ++++++++-
 3 files changed, 40 insertions(+), 5 deletions(-)

diffs (94 lines):

diff -r 5cc9cb480801 -r 3a1121e547e5 usr.sbin/sysinst/bsddisklabel.c
--- a/usr.sbin/sysinst/bsddisklabel.c   Sun Jul 28 16:03:00 2019 +0000
+++ b/usr.sbin/sysinst/bsddisklabel.c   Sun Jul 28 16:30:36 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bsddisklabel.c,v 1.22 2019/07/28 16:03:00 martin Exp $ */
+/*     $NetBSD: bsddisklabel.c,v 1.23 2019/07/28 16:30:36 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -319,8 +319,15 @@
        } else if (pset->infos[opt].mount[0]) {
                mount = pset->infos[opt].mount;
        } else {
-               mount = getfslabelname(pset->infos[opt].fs_type,
-                   pset->infos[opt].fs_version);
+               mount = NULL;
+               if (pset->infos[opt].parts->pscheme->other_partition_identifier
+                   && pset->infos[opt].cur_part_id != NO_PART)
+                       mount = pset->infos[opt].parts->pscheme->
+                           other_partition_identifier(pset->infos[opt].parts,
+                           pset->infos[opt].cur_part_id);
+               if (mount == NULL)
+                       mount = getfslabelname(pset->infos[opt].fs_type,
+                           pset->infos[opt].fs_version);
                mount = str_arg_subst(msg_string(MSG_size_ptn_not_mounted),
                    1, &mount);
                free_mount = true;
diff -r 5cc9cb480801 -r 3a1121e547e5 usr.sbin/sysinst/gpt.c
--- a/usr.sbin/sysinst/gpt.c    Sun Jul 28 16:03:00 2019 +0000
+++ b/usr.sbin/sysinst/gpt.c    Sun Jul 28 16:30:36 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpt.c,v 1.5 2019/07/28 13:17:46 martin Exp $   */
+/*     $NetBSD: gpt.c,v 1.6 2019/07/28 16:30:36 martin Exp $   */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -1423,6 +1423,26 @@
        return true;
 }
 
+static const char *
+gpt_get_label_str(const struct disk_partitions *arg, part_id ptn)
+{
+       const struct gpt_disk_partitions *parts =
+           (const struct gpt_disk_partitions*)arg;
+       size_t i;
+       struct gpt_part_entry *p;
+
+       for (i = 0, p = parts->partitions; p != NULL; i++, p = p->gp_next)
+               if (i == ptn)
+                       break;
+
+       if (p == NULL)
+               return NULL;
+
+       if (p->gp_label[0] != 0)
+               return p->gp_label;
+       return p->gp_id;
+}
+
 static bool
 gpt_format_custom_attribute(const struct disk_partitions *arg,
     part_id ptn, size_t attr_no, const struct disk_part_info *info,
@@ -1570,6 +1590,7 @@
        .format_custom_attribute = gpt_format_custom_attribute,
        .custom_attribute_toggle = gpt_custom_attribute_toggle,
        .custom_attribute_set_str = gpt_custom_attribute_set_str,
+       .other_partition_identifier = gpt_get_label_str,
        .get_part_device = gpt_get_part_device,
        .max_free_space_at = gpt_max_free_space_at,
        .get_free_spaces = gpt_get_free_spaces,
diff -r 5cc9cb480801 -r 3a1121e547e5 usr.sbin/sysinst/partitions.h
--- a/usr.sbin/sysinst/partitions.h     Sun Jul 28 16:03:00 2019 +0000
+++ b/usr.sbin/sysinst/partitions.h     Sun Jul 28 16:30:36 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partitions.h,v 1.3 2019/07/24 02:37:17 msaitoh Exp $   */
+/*     $NetBSD: partitions.h,v 1.4 2019/07/28 16:30:36 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -292,6 +292,13 @@
        bool (*custom_attribute_set_str)(struct disk_partitions*,
            part_id, size_t attr_no, const char *new_val);
 
+       /*
+        * Optional: additional user information when showing the size
+        * editor (especially for existing unknown partitions)
+        */
+       const char * (*other_partition_identifier)(const struct
+           disk_partitions*, part_id);
+
 
        /* Retrieve device and partition names, e.g. for checking
         * against kern.root_device or invoking newfs.



Home | Main Index | Thread Index | Old Index