Add support for dmraid

This commit is contained in:
Dario Corti 2018-07-18 00:15:18 +02:00
parent eb2115a254
commit 137264b090

View File

@ -576,6 +576,56 @@ public class Device : GLib.Object{
find_toplevel_parent(list, part);
}
// Cleanup for dmraid: remove member disks and double children
for (int i = list.size - 1; i >= 0; --i) {
if (list[i].type == "dmraid") {
// This is a dmraid device, lsblk shows one member disk
// as parent and we remove it
for (int j = i - 1; j >= 0; --j) {
if (list[j].kname == list[i].pkname) {
list.remove_at(j);
--i; // we are removing an element before i
break;
}
}
// Does not have a parent anymore
list[i].pkname = "";
// Its children have to be unique (e.g. when mirroring,
// lsblk shows each member partition twice)
for (int j = list.size - 1; j > i; --j) {
if (list[j].pkname == list[i].kname) {
for (int k = j - 1; k >= 0; --k) {
if (list[k].kname == list[j].kname) {
list.remove_at(k);
--j; // we are removing an element between i and j
}
}
}
}
}
}
// Some more cleanup: dmraid are to be seen as disks and need deduplication
for (int i = list.size - 1; i >= 0; --i) {
if (list[i].type == "dmraid") {
// It's now a disk
list[i].type = "disk";
list[i].model = list[i].name;
// We remove other copies of the same dmraid device
for (int j = list.size - 1; j >= 0; --j) {
if ((i != j) && (list[j].type == "dmraid") && (list[j].kname == list[i].kname)) {
list.remove_at(j);
if (j < i)
--i; // we are removing an element before i
}
}
}
}
//find_toplevel_parent();
if (lsblk_is_ancient){