diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-28 12:16:56 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-28 12:16:56 +0000 |
commit | aeb1237dda1465d8dc05755f2ba5894313833c61 (patch) | |
tree | 5e7c7fd63cbc9a888f42f3694432d1615c73b082 /usr.sbin/pkg_add/OpenBSD/Vstat.pm | |
parent | fb0cb3076f322dd92c7246fbcb742b2a50ff3b4f (diff) |
lift up more of the dev checking code into Vstat.
un-special case SpecialFiles on deletion. Now that CONTENTS is part of the
plist, it's checked as well on addition.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/Vstat.pm')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index 6ebe056cba0..0af1ffb1559 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.26 2007/05/27 22:18:14 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.27 2007/05/28 12:16:55 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -71,7 +71,7 @@ sub init_devices() } } close($cmd1) or print STDERR "Error running mount: $!\n"; - $giveup = { used => 0 }; + $giveup = { used => 0, dev => '???' }; bless $giveup, "OpenBSD::Vstat::Failsafe"; } @@ -194,12 +194,49 @@ sub tally() package OpenBSD::Vstat::MountPoint; sub avail { - my $self = $_[0]; + my $self = shift; return $self->{avail} - $self->{used}/$self->{blocksize}; } +sub report_ro +{ + my ($s, $state, $fname) = @_; + + if ($state->{very_verbose} or ++($s->{problems}) < 4) { + print STDERR "Error: ", $s->{dev}, + " is read-only ($fname)\n"; + } elsif ($s->{problems} == 4) { + print STDERR "Error: ... more files on ", $s->{dev}, "\n"; + } + $state->{problems}++; +} + +sub report_overflow +{ + my ($s, $state, $fname) = @_; + + if ($state->{very_verbose} or ++($s->{problems}) < 4) { + print STDERR "Error: ", $s->{dev}, + " is not large enough ($fname)\n"; + } elsif ($s->{problems} == 4) { + print STDERR "Error: ... more files do not fit on ", + $s->{dev}, "\n"; + } + $state->{problems}++; + $state->{overflow} = 1; +} + +sub report_noexec +{ + my ($s, $state, $fname) = @_; + print STDERR "Error: ", $s->{dev}, " is noexec ($fname)\n"; + $state->{problems}++; +} + package OpenBSD::Vstat::Failsafe; +our @ISA=(qw(OpenBSD::Vstat::MountPoint)); + sub avail { return 1; |