improve dataset detection by only including mounted datasets

This commit is contained in:
Christoph Klaffl 2019-11-05 17:19:56 +01:00
parent f745aa25a1
commit 0e5c2e1cff
No known key found for this signature in database
GPG Key ID: 8FC1D76EED4970D2
1 changed files with 7 additions and 2 deletions

View File

@ -102,14 +102,19 @@ sub getdataset {
my ($path) = @_;
open FH, "$zfs list -Ho mountpoint |";
open FH, "$zfs list -H -t filesystem -o mountpoint,mounted |";
my @datasets = <FH>;
close FH;
my @matchingdatasets;
foreach my $dataset (@datasets) {
chomp $dataset;
if ( $path =~ /^$dataset/ ) { push @matchingdatasets, $dataset; }
my ($mountpoint, $mounted) = ($dataset =~ m/([^\t]*)\t*(.*)/);
if ($mounted ne "yes") {
next;
}
if ( $path =~ /^$mountpoint/ ) { push @matchingdatasets, $mountpoint; }
}
my $bestmatch = '';