[pve-devel] [PATCH 2/9] add blockdevices_list sub
Alexandre Derumier
aderumier at odiso.com
Sun Aug 16 19:42:59 CEST 2015
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
src/PVE/LXC.pm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 598b754..fbdc5bb 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1786,4 +1786,18 @@ sub loopdevices_list {
return $loopdev;
}
+
+sub blockdevices_list {
+
+ my $bdevs = {};
+ dir_glob_foreach("/sys/dev/block/", '(\d+):(\d+)', sub {
+ my (undef, $major, $minor) = @_;
+ my $bdev = readlink("/sys/dev/block/$major:$minor");
+ $bdev =~ s/\.\.\/\.\.\/devices\/virtual\/block\//\/dev\//;
+ $bdevs->{$bdev}->{major} = $major;
+ $bdevs->{$bdev}->{minor} = $minor;
+ });
+ return $bdevs;
+}
+
1;
--
2.1.4
More information about the pve-devel
mailing list