read /proc/self/mountinfo for mount info
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 28 Jan 2013 21:35:34 +0000 (16:35 -0500)
committerZhang Qiang <qiang.z.zhang@intel.com>
Mon, 28 Jan 2013 22:15:40 +0000 (17:15 -0500)
the output of 'mount' command are differents for each distros(fedora/
openSUSE/ubuntu), but the format of /proc/self/mountinfo are the same,
and contains all info we need.

Change-Id: I428235b7a08ed666524c99d48a4645aa33663778

depanneur

index 5132e1f..c9f27af 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -1052,18 +1052,15 @@ sub safe_umount {
 sub mount_source_check {
     my $build_root = canonpath(shift);
 
-    my (undef, $tmp_file) = tempfile(CLEANUP=>1, OPEN => 0);
-    if (my_system("mount -l >$tmp_file 2>/dev/null") == 0) {
-        open my $file, '<', $tmp_file or die $!;
-        while (<$file>) {
-            chomp;
-            next if ($_ !~ /$build_root/);
-            my @mount_info= split(' ', $_);
-            if (-e $mount_info[0] and -e "$mount_info[0]/.git"){
-                error("$mount_info[0] has been mounted to $mount_info[2]. " .
-                      "Please unmount it manually to avoid being deleted " .
-                      "unexpectly.");
-            }
+    open my $file, '<', "/proc/self/mountinfo" or die $!;
+    while (<$file>) {
+        chomp;
+        next if ($_ !~ /$build_root/);
+        my @mount_info= split(' ', $_);
+        if (-e $mount_info[3] and -e "$mount_info[3]/.git"){
+            error("$mount_info[3] has been mounted to $mount_info[4]. " .
+                  "Please unmount it manually to avoid being deleted " .
+                  "unexpectly.");
         }
     }
 }