DIsk space function cleanups
authorJamie Cameron <jcameron@webmin.com>
Thu, 7 Aug 2008 18:21:27 +0000 (18:21 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 7 Aug 2008 18:21:27 +0000 (18:21 +0000)
mount/freebsd-lib.pl
mount/hpux-lib.pl
mount/irix-lib.pl
mount/linux-lib.pl
mount/macos-lib.pl
mount/netbsd-lib.pl
mount/openbsd-lib.pl
mount/osf1-lib.pl
mount/solaris-lib.pl
mount/unixware-lib.pl

index 167e588..c756963 100755 (executable)
@@ -319,7 +319,8 @@ sub disk_space
 {
 if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
-&execute_command("df -k $_[1]", undef, \$out, undef, 0, 1);
+my $out;
+&execute_command("df -k ".quotemeta($_[1]), undef, \$out, undef, 0, 1);
 if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index a59b866..b66c767 100644 (file)
@@ -230,8 +230,8 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "swap") {
        return ();
        }
-local $out;
-&execute_command("bdf $_[1]", undef, \$out, \$out, 0, 1);
+my $out;
+&execute_command("bdf ".quotemeta($_[1]), undef, \$out, \$out, 0, 1);
 if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index 4e3c418..26219d8 100644 (file)
@@ -267,7 +267,7 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "fd" || $_[0] eq "proc" || $_[0] eq "swap" || $_[0] eq "autofs") {
        return ();
        }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index 0aba425..0aef4df 100644 (file)
@@ -830,7 +830,7 @@ sub disk_space
 if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "proc" || $_[0] eq "swap" ||
     $_[0] eq "auto" || $_[0] eq "autofs") { return (); }
-local $out = &backquote_command("LC_ALL='' LANG='' df -k $_[1]", 1);
+local $out = &backquote_command("LC_ALL='' LANG='' df -k ".quotemeta($_[1]), 1);
 if ($out =~ /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index b41874b..e50e102 100755 (executable)
@@ -107,7 +107,7 @@ sub disk_space
 {
 if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index c8c8711..b7a9bef 100755 (executable)
@@ -231,7 +231,7 @@ sub disk_space
 {
 if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index c50e50d..b6d8770 100755 (executable)
@@ -231,7 +231,7 @@ sub disk_space
 {
 if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "proc" || $_[0] eq "swap") { return (); }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index 0c0fd38..9d4f798 100644 (file)
@@ -262,7 +262,7 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "fd" || $_[0] eq "proc" || $_[0] eq "swap" || $_[0] eq "autofs") {
        return ();
        }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }
index f8902c5..5f4a660 100644 (file)
@@ -330,9 +330,15 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "fd" || $_[0] eq "proc" || $_[0] eq "swap" || $_[0] eq "autofs") {
        return ();
        }
-if (&backquote_command("df -k $_[1]", 1) =~
-    /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
-       return ($1, $2);
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
+    /Mounted on\n\S+\s+(\S+)\s+(\S+)\s+(\S+)/) {
+       if ($1 == 0) {
+               # Size is sometimes zero on Solaris? Fake it..
+               return ($2+$3, $3);
+               }
+       else {
+               return ($1, $3);
+               }
        }
 return ( );
 }
index 320f87b..39f8d2f 100755 (executable)
@@ -318,7 +318,7 @@ if (&get_mounted($_[1], "*") < 0) { return (); }
 if ($_[0] eq "fd" || $_[0] eq "proc" || $_[0] eq "swap" || $_[0] eq "autofs") {
        return ();
        }
-if (&backquote_command("df -k $_[1]", 1) =~
+if (&backquote_command("df -k ".quotemeta($_[1]), 1) =~
     /Mounted on\n\S+\s+(\S+)\s+\S+\s+(\S+)/) {
        return ($1, $2);
        }