[pve-devel] [PATCH pve-storage] make use of the new ProcFSTools::parse_proc_mounts

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Nov 13 12:21:44 CET 2015


---
 PVE/Storage/GlusterfsPlugin.pm | 17 +++++++++--------
 PVE/Storage/NFSPlugin.pm       | 18 +++++++++---------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/PVE/Storage/GlusterfsPlugin.pm b/PVE/Storage/GlusterfsPlugin.pm
index 3bae100..a6ca950 100644
--- a/PVE/Storage/GlusterfsPlugin.pm
+++ b/PVE/Storage/GlusterfsPlugin.pm
@@ -70,12 +70,13 @@ my $get_active_server = sub {
 sub glusterfs_is_mounted {
     my ($volume, $mountpoint, $mountdata) = @_;
 
-    $mountdata = PVE::ProcFSTools::read_proc_mounts() if !$mountdata;
-
-    if ($mountdata =~ m|^\S+:$volume/?\s$mountpoint\sfuse.glusterfs|m) {
-	return $mountpoint;
-    }
+    $mountdata = PVE::ProcFSTools::parse_proc_mounts() if !$mountdata;
 
+    return $mountpoint if grep {
+	$_->[2] eq 'fuse.glusterfs' &&
+	$_->[0] eq $volume &&
+	$_->[1] eq $mountpoint
+    } @$mountdata;
     return undef;
 }
 
@@ -248,7 +249,7 @@ sub alloc_image {
 sub status {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
@@ -263,7 +264,7 @@ sub status {
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
@@ -287,7 +288,7 @@ sub activate_storage {
 sub deactivate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm
index 5282055..047c3a4 100644
--- a/PVE/Storage/NFSPlugin.pm
+++ b/PVE/Storage/NFSPlugin.pm
@@ -20,12 +20,12 @@ sub nfs_is_mounted {
     $server = "[$server]" if Net::IP::ip_is_ipv6($server);
     my $source = "$server:$export";
 
-    $mountdata = PVE::ProcFSTools::read_proc_mounts() if !$mountdata;
-
-    if ($mountdata =~ m|^\Q$source\E/?\s\Q$mountpoint\E\snfs|m) {
-	return $mountpoint;
-    } 
-
+    $mountdata = PVE::ProcFSTools::parse_proc_mounts() if !$mountdata;
+    return $mountpoint if grep {
+	$_->[2] eq 'nfs' &&
+	$_->[0] eq $source &&
+	$_->[1] eq $mountpoint
+    } @$mountdata;
     return undef;
 }
 
@@ -102,7 +102,7 @@ sub check_config {
 sub status {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
@@ -117,7 +117,7 @@ sub status {
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
@@ -143,7 +143,7 @@ sub activate_storage {
 sub deactivate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
-    $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts()
+    $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
 	if !$cache->{mountdata};
 
     my $path = $scfg->{path};
-- 
2.1.4





More information about the pve-devel mailing list