Module Name: src Committed By: martin Date: Sun Jul 28 16:30:36 UTC 2019
Modified Files: src/usr.sbin/sysinst: bsddisklabel.c gpt.c partitions.h Log Message: If available, show additional names of foreign partitions in the size menu. Makes installing on machines with other OSes installed a lot less confusing. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/sysinst/bsddisklabel.c cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/sysinst/gpt.c cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/partitions.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/sysinst/bsddisklabel.c diff -u src/usr.sbin/sysinst/bsddisklabel.c:1.22 src/usr.sbin/sysinst/bsddisklabel.c:1.23 --- src/usr.sbin/sysinst/bsddisklabel.c:1.22 Sun Jul 28 16:03:00 2019 +++ src/usr.sbin/sysinst/bsddisklabel.c Sun Jul 28 16:30:36 2019 @@ -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 @@ draw_size_menu_line(menudesc *m, int opt } 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; Index: src/usr.sbin/sysinst/gpt.c diff -u src/usr.sbin/sysinst/gpt.c:1.5 src/usr.sbin/sysinst/gpt.c:1.6 --- src/usr.sbin/sysinst/gpt.c:1.5 Sun Jul 28 13:17:46 2019 +++ src/usr.sbin/sysinst/gpt.c Sun Jul 28 16:30:36 2019 @@ -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 @@ gpt_custom_attribute_writable(const stru 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 @@ gpt_parts = { .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, Index: src/usr.sbin/sysinst/partitions.h diff -u src/usr.sbin/sysinst/partitions.h:1.3 src/usr.sbin/sysinst/partitions.h:1.4 --- src/usr.sbin/sysinst/partitions.h:1.3 Wed Jul 24 02:37:17 2019 +++ src/usr.sbin/sysinst/partitions.h Sun Jul 28 16:30:36 2019 @@ -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 @@ struct disk_partitioning_scheme { 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.