dissect: automatically detect boot loader spec $BOOT partition
The boot loader spec supports two places to store boot loader configuration: the ESP and a generic replacement for it in case the ESP is not available or not suitable. Let's look for both.
This commit is contained in:
parent
7b5de29569
commit
a8c47660bb
|
@ -495,6 +495,14 @@ int dissect_image(
|
||||||
|
|
||||||
designator = PARTITION_ESP;
|
designator = PARTITION_ESP;
|
||||||
fstype = "vfat";
|
fstype = "vfat";
|
||||||
|
|
||||||
|
} else if (sd_id128_equal(type_id, GPT_XBOOTLDR)) {
|
||||||
|
|
||||||
|
if (pflags & GPT_FLAG_NO_AUTO)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
designator = PARTITION_XBOOTLDR;
|
||||||
|
rw = !(pflags & GPT_FLAG_READ_ONLY);
|
||||||
}
|
}
|
||||||
#ifdef GPT_ROOT_NATIVE
|
#ifdef GPT_ROOT_NATIVE
|
||||||
else if (sd_id128_equal(type_id, GPT_ROOT_NATIVE)) {
|
else if (sd_id128_equal(type_id, GPT_ROOT_NATIVE)) {
|
||||||
|
@ -610,21 +618,53 @@ int dissect_image(
|
||||||
|
|
||||||
} else if (is_mbr) {
|
} else if (is_mbr) {
|
||||||
|
|
||||||
if (pflags != 0x80) /* Bootable flag */
|
switch (blkid_partition_get_type(pp)) {
|
||||||
continue;
|
|
||||||
|
|
||||||
if (blkid_partition_get_type(pp) != 0x83) /* Linux partition */
|
case 0x83: /* Linux partition */
|
||||||
continue;
|
|
||||||
|
|
||||||
if (generic_node)
|
if (pflags != 0x80) /* Bootable flag */
|
||||||
multiple_generic = true;
|
continue;
|
||||||
else {
|
|
||||||
generic_nr = nr;
|
if (generic_node)
|
||||||
generic_rw = true;
|
multiple_generic = true;
|
||||||
generic_node = strdup(node);
|
else {
|
||||||
if (!generic_node)
|
generic_nr = nr;
|
||||||
|
generic_rw = true;
|
||||||
|
generic_node = strdup(node);
|
||||||
|
if (!generic_node)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0xEA: { /* Boot Loader Spec extended $BOOT partition */
|
||||||
|
_cleanup_free_ char *n = NULL;
|
||||||
|
sd_id128_t id = SD_ID128_NULL;
|
||||||
|
const char *sid;
|
||||||
|
|
||||||
|
/* First one wins */
|
||||||
|
if (m->partitions[PARTITION_XBOOTLDR].found)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sid = blkid_partition_get_uuid(pp);
|
||||||
|
if (sid)
|
||||||
|
(void) sd_id128_from_string(sid, &id);
|
||||||
|
|
||||||
|
n = strdup(node);
|
||||||
|
if (!n)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
m->partitions[PARTITION_XBOOTLDR] = (DissectedPartition) {
|
||||||
|
.found = true,
|
||||||
|
.partno = nr,
|
||||||
|
.rw = true,
|
||||||
|
.architecture = _ARCHITECTURE_INVALID,
|
||||||
|
.node = TAKE_PTR(n),
|
||||||
|
.uuid = id,
|
||||||
|
};
|
||||||
|
|
||||||
|
break;
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,6 +1537,7 @@ static const char *const partition_designator_table[] = {
|
||||||
[PARTITION_HOME] = "home",
|
[PARTITION_HOME] = "home",
|
||||||
[PARTITION_SRV] = "srv",
|
[PARTITION_SRV] = "srv",
|
||||||
[PARTITION_ESP] = "esp",
|
[PARTITION_ESP] = "esp",
|
||||||
|
[PARTITION_XBOOTLDR] = "xbootldr",
|
||||||
[PARTITION_SWAP] = "swap",
|
[PARTITION_SWAP] = "swap",
|
||||||
[PARTITION_ROOT_VERITY] = "root-verity",
|
[PARTITION_ROOT_VERITY] = "root-verity",
|
||||||
[PARTITION_ROOT_SECONDARY_VERITY] = "root-secondary-verity",
|
[PARTITION_ROOT_SECONDARY_VERITY] = "root-secondary-verity",
|
||||||
|
|
|
@ -29,6 +29,7 @@ enum {
|
||||||
PARTITION_HOME,
|
PARTITION_HOME,
|
||||||
PARTITION_SRV,
|
PARTITION_SRV,
|
||||||
PARTITION_ESP,
|
PARTITION_ESP,
|
||||||
|
PARTITION_XBOOTLDR,
|
||||||
PARTITION_SWAP,
|
PARTITION_SWAP,
|
||||||
PARTITION_ROOT_VERITY, /* verity data for the PARTITION_ROOT partition */
|
PARTITION_ROOT_VERITY, /* verity data for the PARTITION_ROOT partition */
|
||||||
PARTITION_ROOT_SECONDARY_VERITY, /* verity data for the PARTITION_ROOT_SECONDARY partition */
|
PARTITION_ROOT_SECONDARY_VERITY, /* verity data for the PARTITION_ROOT_SECONDARY partition */
|
||||||
|
|
Loading…
Reference in a new issue