From bb5520eb17c2a28ccdf11e59be84a7058a2b60ab Mon Sep 17 00:00:00 2001 From: Wolfgang Link Date: Thu, 3 Sep 2015 08:51:46 +0200 Subject: [PATCH] move read_proc_mounts from NFSPlugin to Tools. this function will be uesd in more path of the code. --- PVE/Storage/NFSPlugin.pm | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm index 68764b7..5282055 100644 --- a/PVE/Storage/NFSPlugin.pm +++ b/PVE/Storage/NFSPlugin.pm @@ -6,6 +6,7 @@ use IO::File; use Net::IP; use File::Path; use PVE::Tools qw(run_command); +use PVE::ProcFSTools; use PVE::Storage::Plugin; use PVE::JSONSchema qw(get_standard_option); @@ -13,26 +14,13 @@ use base qw(PVE::Storage::Plugin); # NFS helper functions -sub read_proc_mounts { - - local $/; # enable slurp mode - - my $data = ""; - if (my $fd = IO::File->new("/proc/mounts", "r")) { - $data = <$fd>; - close ($fd); - } - - return $data; -} - sub nfs_is_mounted { my ($server, $export, $mountpoint, $mountdata) = @_; $server = "[$server]" if Net::IP::ip_is_ipv6($server); my $source = "$server:$export"; - $mountdata = read_proc_mounts() if !$mountdata; + $mountdata = PVE::ProcFSTools::read_proc_mounts() if !$mountdata; if ($mountdata =~ m|^\Q$source\E/?\s\Q$mountpoint\E\snfs|m) { return $mountpoint; @@ -114,7 +102,8 @@ sub check_config { sub status { my ($class, $storeid, $scfg, $cache) = @_; - $cache->{mountdata} = read_proc_mounts() if !$cache->{mountdata}; + $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts() + if !$cache->{mountdata}; my $path = $scfg->{path}; my $server = $scfg->{server}; @@ -128,7 +117,8 @@ sub status { sub activate_storage { my ($class, $storeid, $scfg, $cache) = @_; - $cache->{mountdata} = read_proc_mounts() if !$cache->{mountdata}; + $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts() + if !$cache->{mountdata}; my $path = $scfg->{path}; my $server = $scfg->{server}; @@ -153,7 +143,8 @@ sub activate_storage { sub deactivate_storage { my ($class, $storeid, $scfg, $cache) = @_; - $cache->{mountdata} = read_proc_mounts() if !$cache->{mountdata}; + $cache->{mountdata} = PVE::ProcFSTools::read_proc_mounts() + if !$cache->{mountdata}; my $path = $scfg->{path}; my $server = $scfg->{server};