]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/ProcFSTools.pm
is_mounted: use realpath on the mountpoint
[pve-common.git] / src / PVE / ProcFSTools.pm
index fea539a563f1f6e8eee1770e3999fbbb962e1f87..368ae73a1674b93018d1df9505604c7746f07811 100644 (file)
@@ -6,6 +6,7 @@ use POSIX;
 use Time::HiRes qw (gettimeofday);
 use IO::File;
 use PVE::Tools;
+use Cwd;
 
 my $clock_ticks = POSIX::sysconf(&POSIX::_SC_CLK_TCK);
 
@@ -288,6 +289,20 @@ sub read_proc_mounts {
     return PVE::Tools::file_get_contents("/proc/mounts");
 }
 
+sub is_mounted {
+    my ($mountpoint) = @_;
+
+    $mountpoint = Cwd::realpath($mountpoint);
+
+    my $mountdata = read_proc_mounts();
+
+    if ($mountdata =~ m/\s$mountpoint\s/) {
+       return 1;
+    } else {
+       return 0;
+    }
+}
+
 sub read_proc_net_ipv6_route {
     my $filename = "/proc/net/ipv6_route";