summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-03-07 11:24:08 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-03-07 11:24:08 +0000
commitbac9468194d4158f1dc6bd345917a28b83ad62bf (patch)
tree293b6b72726a3edc15e6e9b4833b1715bceec185 /usr.sbin/pkg_add
parent0871cc42c029bf74a16aafb13b6b39196160158e (diff)
fix size checks for good. Since we want deletion to happen `right now'
but size accounting to happen later, just mark the size to delete `for later', do not take them into account for avail(), and synchronize() at the right time, e.g., after addition when updating, and right away for straight deletion. okay deraadt@
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Vstat.pm22
-rw-r--r--usr.sbin/pkg_add/pkg_add3
3 files changed, 23 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 61b778a07c9..e572b185955 100644
--- a/usr.sbin/pkg_add/OpenBSD/Delete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Delete.pm,v 1.33 2006/10/18 16:40:40 sturm Exp $
+# $OpenBSD: Delete.pm,v 1.34 2007/03/07 11:24:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -147,6 +147,7 @@ sub delete_package
}
validate_plist($plist, $state);
+ OpenBSD::Vstat::synchronize();
delete_plist($plist, $state);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
index 7308f680b2e..d31de4e0c6e 100644
--- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Vstat.pm,v 1.17 2007/03/07 00:09:46 espie Exp $
+# $OpenBSD: Vstat.pm,v 1.18 2007/03/07 11:24:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -37,7 +37,7 @@ sub create_device($)
my $dev = shift;
my $n = $devinfo->{$dev};
if (!defined $n) {
- $n = { dev => $dev, used => 0, problems => 0 };
+ $n = { dev => $dev, used => 0, delayed => 0, problems => 0 };
bless $n, "OpenBSD::Vstat::MountPoint";
$devinfo->{$dev} = $n;
}
@@ -143,6 +143,22 @@ sub account_for($$)
return $e;
}
+sub account_later($$)
+{
+ my ($name, $size) = @_;
+ my $e = filestat($name);
+ $e->{delayed} += $size;
+ return $e;
+}
+
+sub synchronize
+{
+ while (my ($k, $v) = each %$devinfo) {
+ $v->{used} += $v->{delayed};
+ $v->{delayed} = 0;
+ }
+}
+
sub add($$;$)
{
my ($name, $size, $value) = @_;
@@ -158,7 +174,7 @@ sub remove($$)
{
my ($name, $size) = @_;
$virtual->{$name} = 0;
- return defined($size) ? account_for($name, -$size) : undef;
+ return defined($size) ? account_later($name, -$size) : undef;
}
sub tally()
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index e4e720bd84b..7c2f6529bbc 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.223 2007/03/07 00:09:46 espie Exp $
+# $OpenBSD: pkg_add,v 1.224 2007/03/07 11:24:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -281,6 +281,7 @@ sub really_add($$)
print "\n";
}
my $totsize = OpenBSD::Add::validate_plist($plist, $state);
+ OpenBSD::Vstat::synchronize();
if (!defined $handle) {
Fatal "Archive in $pkgname broken";