diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-05 11:00:58 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-05 11:00:58 +0000 |
commit | 001f3c0cbe2aecd8671e8ac6a8e1a13d6de8a48c (patch) | |
tree | f67b0477211fcc83a58ffd79aa7cdc077f4fc0e1 /usr.sbin/pkg_add | |
parent | f3c71d850fdf6fb10c8709d675812106bc97f503 (diff) |
auto-create giveup, so it's defined if we call tally without doing anything.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index e5762d692b4..ab67914b81f 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.53 2010/01/03 09:30:40 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.54 2010/01/05 11:00:57 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -133,6 +133,14 @@ my $devinfo; my $devinfo2; my $giveup; +sub giveup +{ + if (!defined $giveup) { + $giveup = OpenBSD::MountPoint::Fail->new; + } + return $giveup; +} + sub new { my ($class, $dev, $opts) = @_; @@ -167,7 +175,6 @@ sub ask_mount { my ($class, $state) = shift; - $giveup = OpenBSD::MountPoint::Fail->new; delete $ENV{'BLOCKSIZE'}; run($state, OpenBSD::Paths->mount, sub { my $_ = shift; @@ -185,7 +192,7 @@ sub ask_df { my ($class, $fname, $state) = @_; - my $info = $giveup; + my $info = $class->giveup; my $blocksize = 512; $class->ask_mount($state) if !defined $devinfo; @@ -212,7 +219,7 @@ sub find { my ($class, $dev, $fname, $state) = @_; if (!defined $dev) { - return $giveup; + return $class->giveup; } if (!defined $devinfo2->{$dev}) { $devinfo2->{$dev} = $class->ask_df($fname, $state); @@ -238,7 +245,7 @@ sub tally { my ($self, $state) = @_; - for my $v ((sort {$a->name cmp $b->name } values %$devinfo2), $giveup) { + for my $v ((sort {$a->name cmp $b->name } values %$devinfo2), $self->giveup) { $v->tally($state); } } |