Merge pull request #450 from phreaker0/fix-dataset-detection

improve dataset detection by only including mounted datasets
This commit is contained in:
Jim Salter 2020-01-16 13:52:26 -05:00 committed by GitHub
commit 03e523ff01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 = '';