diff options
author | Maarten Vanraes <alien@mageia.org> | 2016-08-06 14:33:08 +0200 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-08-06 14:33:08 +0200 |
commit | 10404b2a580be87ed7fbd5dbb25d0f71bedb56cd (patch) | |
tree | 02f9be2ba154ac47822b6e325884b395ce791d9b /lib/ManaTools/Shared/disk_backend/Mountable.pm | |
parent | b30d967dc49238fcb1e20156bc3d2f53111e17c8 (diff) | |
download | manatools-10404b2a580be87ed7fbd5dbb25d0f71bedb56cd.tar manatools-10404b2a580be87ed7fbd5dbb25d0f71bedb56cd.tar.gz manatools-10404b2a580be87ed7fbd5dbb25d0f71bedb56cd.tar.bz2 manatools-10404b2a580be87ed7fbd5dbb25d0f71bedb56cd.tar.xz manatools-10404b2a580be87ed7fbd5dbb25d0f71bedb56cd.zip |
Mountable: allow to get mountsource in order to match later
Diffstat (limited to 'lib/ManaTools/Shared/disk_backend/Mountable.pm')
-rw-r--r-- | lib/ManaTools/Shared/disk_backend/Mountable.pm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/disk_backend/Mountable.pm b/lib/ManaTools/Shared/disk_backend/Mountable.pm index 33cb1463..441333e2 100644 --- a/lib/ManaTools/Shared/disk_backend/Mountable.pm +++ b/lib/ManaTools/Shared/disk_backend/Mountable.pm @@ -61,6 +61,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use Moose::Role; +requires '_get_mount_source'; + +has 'mountsource' => ( + is => 'ro', + isa => 'Maybe[Str]', +); + +around 'mountsource' => sub { + my $orig = shift; + my $self = shift; + + return $self->_get_mount_source(); +}; + +has 'mountsourcepath' => ( + is => 'ro', + isa => 'Str', + default => '/', +); + +sub mountsourcedevice { + my $self = shift; + my $mountsource = $self->mountsource(); + my @s = stat($mountsource); + # check if found and blockdevice + return $mountsource if (scalar(@s) < 7 || ($s[2] >> 12) != 6); + + # get the major and minor + my $minor = $s[6] % 256; + my $major = int (($s[6] - $minor) / 256); + return $major .':'. $minor; +} + #============================================================= =head2 find_path |