From 4ee9e61cc2c698897af40d56df5344b8797f31c3 Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Sat, 6 Aug 2016 13:59:38 +0200 Subject: Mountable: allow to find the mount path --- lib/ManaTools/Shared/disk_backend/BlockDevice.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib/ManaTools/Shared/disk_backend/BlockDevice.pm') diff --git a/lib/ManaTools/Shared/disk_backend/BlockDevice.pm b/lib/ManaTools/Shared/disk_backend/BlockDevice.pm index f20c0fda..9acce67e 100644 --- a/lib/ManaTools/Shared/disk_backend/BlockDevice.pm +++ b/lib/ManaTools/Shared/disk_backend/BlockDevice.pm @@ -190,4 +190,27 @@ sub sync_majorminor { } } +#============================================================= + +=head2 find_path + +=head3 DESCRIPTION + + this method finds in descendants the Mount part and gets the path from it + +=cut + +#============================================================= +sub find_path { + my $self = shift; + my $partstate = shift; + # finding a path only works if one has a Mount or Mountable child, + my @children = $self->children($partstate); + for my $child (@children) { + return $child->path() if ($child->isa('ManaTools::Shared::disk_backend::Part::Mount')); + return $child->find_path($partstate) if ($child->does('ManaTools::Shared::disk_backend::Mountable')); + } + return undef; +} + 1; -- cgit v1.2.1