PR 55378: do not assume RAW_PART to be either 2 or 3

This commit is contained in:
martin 2020-09-28 18:40:23 +00:00
parent 7886d74d77
commit 07c7ef657d
3 changed files with 17 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: README.md_defs,v 1.4 2020/01/20 21:26:35 martin Exp $ */
/* $NetBSD: README.md_defs,v 1.5 2020/09/28 18:40:23 martin Exp $ */
The following is trying to document the most important machine dependent
defines used in the sysinst code.
@ -92,7 +92,7 @@ if something fails.
HAVE_PLAIN_DISKLABEL_BOOT may be undefined, only used on architectures
that have MBR as primary with disklabel as
secondary partitioning scheme (RAW_PART != 2)
secondary partitioning scheme (RAW_PART == 3)
used like:

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklabel.c,v 1.37 2020/02/19 21:45:09 martin Exp $ */
/* $NetBSD: disklabel.c,v 1.38 2020/09/28 18:40:23 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@ -172,7 +172,7 @@ disklabel_parts_new(const char *dev, daddr_t start, daddr_t len,
strncpy(parts->l.d_packname, "fictious", sizeof parts->l.d_packname);
#if RAW_PART > 2
#if RAW_PART == 3
if (parts->dp.parent != NULL) {
parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED;
parts->l.d_partitions[RAW_PART-1].p_offset = start;
@ -231,7 +231,7 @@ disklabel_parts_read(const char *disk, daddr_t start, daddr_t len, size_t bps,
close(fd);
return NULL;
}
#if RAW_PART > 2
#if RAW_PART == 3
if (parts->l.d_partitions[RAW_PART-1].p_fstype == FS_UNUSED) {
daddr_t dlstart = parts->l.d_partitions[RAW_PART-1].p_offset;
daddr_t dlend = start +
@ -467,7 +467,7 @@ disklabel_delete_all(struct disk_partitions *arg)
memset(&parts->l.d_partitions, 0, sizeof(parts->l.d_partitions));
parts->dp.num_part = 0;
#if RAW_PART > 2
#if RAW_PART == 3
if (parts->dp.parent != NULL) {
parts->l.d_partitions[RAW_PART-1].p_fstype = FS_UNUSED;
parts->l.d_partitions[RAW_PART-1].p_offset =
@ -501,7 +501,7 @@ disklabel_delete(struct disk_partitions *arg, part_id id,
if (ndx == id) {
if (part == RAW_PART
#if RAW_PART > 2
#if RAW_PART == 3
|| (part == RAW_PART-1 &&
parts->dp.parent != NULL)
#endif
@ -543,7 +543,7 @@ disklabel_delete_range(struct disk_partitions *arg, daddr_t r_start,
daddr_t start = parts->l.d_partitions[part].p_offset;
daddr_t end = start + parts->l.d_partitions[part].p_size;
#if RAW_PART > 2
#if RAW_PART == 3
if (parts->dp.parent != NULL &&
part == RAW_PART - 1 && start == r_start &&
r_start + r_size == end)
@ -759,7 +759,7 @@ disklabel_get_part_info(const struct disk_partitions *arg, part_id id,
parts->l.d_partitions[part].p_fstype == FS_UNUSED)
info->flags |=
PTI_PSCHEME_INTERNAL|PTI_RAW_PART;
#if RAW_PART > 2
#if RAW_PART == 3
if (part == (RAW_PART-1) && parts->dp.parent != NULL &&
parts->l.d_partitions[part].p_fstype == FS_UNUSED)
info->flags |=
@ -906,7 +906,7 @@ disklabel_can_add_partition(const struct disk_partitions *arg)
for (i = 0; i < parts->l.d_npartitions; i++) {
if (i == RAW_PART)
continue;
#if RAW_PART > 2
#if RAW_PART == 3
if (i == RAW_PART-1 && parts->dp.parent != NULL)
continue;
#endif
@ -1061,7 +1061,7 @@ disklabel_add_partition(struct disk_partitions *arg,
continue;
if (i == RAW_PART)
continue;
#if RAW_PART > 2
#if RAW_PART == 3
if (i == RAW_PART-1 && parts->dp.parent != NULL)
continue;
#endif
@ -1124,7 +1124,7 @@ disklabel_add_outer_partition(struct disk_partitions *arg,
continue;
if (i == RAW_PART)
continue;
#if RAW_PART > 2
#if RAW_PART == 3
if (i == RAW_PART-1 && parts->dp.parent != NULL)
continue;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: partitions.c,v 1.10 2020/01/28 07:43:42 martin Exp $ */
/* $NetBSD: partitions.c,v 1.11 2020/09/28 18:40:23 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@ -133,7 +133,7 @@ extern const struct disk_partitioning_scheme gpt_parts;
extern const struct disk_partitioning_scheme mbr_parts;
#endif
#if RAW_PART != 2
#if RAW_PART == 3
static struct disk_partitioning_scheme only_disklabel_parts;
/*
@ -163,7 +163,7 @@ partitions_init(void)
* only offer very few entries.
*/
static const struct part_scheme_desc all_descs[] = {
#if RAW_PART == 2 /* only available as primary on some architectures */
#if RAW_PART != 3 /* only available as primary on some architectures */
{ NULL, &disklabel_parts },
#endif
#ifdef HAVE_GPT
@ -172,7 +172,7 @@ static const struct part_scheme_desc all_descs[] = {
#ifdef HAVE_MBR
{ NULL, &mbr_parts },
#endif
#if RAW_PART != 2 /* "whole disk NetBSD" disklabel variant */
#if RAW_PART == 3 /* "whole disk NetBSD" disklabel variant */
{ NULL, &only_disklabel_parts },
#endif
};
@ -184,7 +184,7 @@ static const struct part_scheme_desc all_descs[] = {
check_available_binaries();
#if RAW_PART != 2
#if RAW_PART == 3
/* generate a variant of disklabel w/o parent scheme */
only_disklabel_parts = disklabel_parts;
only_disklabel_parts.name = MSG_parttype_only_disklabel;