diff mbox

[OSSTEST,2/6] cr-ensure-disk-space: -F option

Message ID 1475583994-30203-2-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Oct. 4, 2016, 12:26 p.m. UTC
May be repeated (cuddled with itself) or given a number.  Forces
deletion, even if there is enough space.  Normally clean up one less
flight than specified, since cr-ensure-disk-space reruns its check
after acquiring the lock.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 cr-ensure-disk-space | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/cr-ensure-disk-space b/cr-ensure-disk-space
index bfdbcc5..c65423a 100755
--- a/cr-ensure-disk-space
+++ b/cr-ensure-disk-space
@@ -26,6 +26,7 @@  use Osstest::Management qw(:logs);
 use Fcntl qw(:flock);
 
 our $dryrun= 0;
+our $force;
 
 open DEBUG, ">/dev/null" or die $!;
 
@@ -34,6 +35,10 @@  while (@ARGV && $ARGV[0] =~ m/^\-/) {
     last if $_ eq '--';
     if (m/^-n$/) {
         $dryrun= 1;
+    } elsif (m/^-(F+)$/) {
+        $force += length $1;
+    } elsif (m/^-F(\d+)$/) {
+        $force += $1;
     } elsif (m/^-D$/) {
         open DEBUG, ">&2" or die $!;
     } else {
@@ -58,6 +63,11 @@  sub check_space () {
     $!=0; $?=0; close P or die "$! $?";
     my $space= $1;
     printf "space: %8d, wanted: %8d ", $space, logcfg('MinSpaceMby');
+    if ($force) {
+	$force--;
+	printf "FORCING ";
+	return 0;
+    }
     return $space >= logcfg('MinSpaceMby');
 }