From: Patrick Plenefisch Date: Sat, 4 Jan 2025 20:02:54 +0000 (-0500) Subject: disk/lvm: Add support for integrity LV X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a37d6114593417bbd29b2d2c3794c05305e9ebe;p=thirdparty%2Fgrub.git disk/lvm: Add support for integrity LV The LV matching must be done after processing the ignored feature indirections, as integrity volumes & caches may have several levels of indirection that the segments must be shifted through. Signed-off-by: Patrick Plenefisch Reviewed-by: Daniel Kiper --- diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index f17b43655..14839a65b 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -817,8 +817,12 @@ grub_lvm_detect (grub_disk_t disk, seg->nodes[seg->node_count - 1].name = tmp; } } - else if (grub_memcmp (p, "cache\"", - sizeof ("cache\"") - 1) == 0) + /* + * Cache and integrity LVs have extra parts that + * we can ignore for our read-only access. + */ + else if (grub_strncmp (p, "cache\"", sizeof ("cache\"") - 1) == 0 || + grub_strncmp (p, "integrity\"", sizeof ("integrity\"") - 1) == 0) { struct ignored_feature_lv *ignored_feature = NULL; @@ -948,36 +952,6 @@ grub_lvm_detect (grub_disk_t disk, } } - /* Match lvs. */ - { - struct grub_diskfilter_lv *lv1; - struct grub_diskfilter_lv *lv2; - for (lv1 = vg->lvs; lv1; lv1 = lv1->next) - for (i = 0; i < lv1->segment_count; i++) - for (j = 0; j < lv1->segments[i].node_count; j++) - { - if (vg->pvs) - for (pv = vg->pvs; pv; pv = pv->next) - { - if (! grub_strcmp (pv->name, - lv1->segments[i].nodes[j].name)) - { - lv1->segments[i].nodes[j].pv = pv; - break; - } - } - if (lv1->segments[i].nodes[j].pv == NULL) - for (lv2 = vg->lvs; lv2; lv2 = lv2->next) - { - if (lv1 == lv2) - continue; - if (grub_strcmp (lv2->name, - lv1->segments[i].nodes[j].name) == 0) - lv1->segments[i].nodes[j].lv = lv2; - } - } - - } { struct ignored_feature_lv *ignored_feature; @@ -1029,6 +1003,37 @@ grub_lvm_detect (grub_disk_t disk, } } + /* Match LVs. Must be done after cache and integrity are found. */ + { + struct grub_diskfilter_lv *lv1; + struct grub_diskfilter_lv *lv2; + + for (lv1 = vg->lvs; lv1; lv1 = lv1->next) + for (i = 0; i < lv1->segment_count; i++) + for (j = 0; j < lv1->segments[i].node_count; j++) + { + if (vg->pvs) + for (pv = vg->pvs; pv; pv = pv->next) + { + if (! grub_strcmp (pv->name, + lv1->segments[i].nodes[j].name)) + { + lv1->segments[i].nodes[j].pv = pv; + break; + } + } + if (lv1->segments[i].nodes[j].pv == NULL) + for (lv2 = vg->lvs; lv2; lv2 = lv2->next) + { + if (lv1 == lv2) + continue; + if (grub_strcmp (lv2->name, + lv1->segments[i].nodes[j].name) == 0) + lv1->segments[i].nodes[j].lv = lv2; + } + } + } + grub_lvm_free_ignored_feature_lvs (ignored_feature_lvs); if (grub_diskfilter_vg_register (vg)) goto fail4;