From aeb1237dda1465d8dc05755f2ba5894313833c61 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Mon, 28 May 2007 12:16:56 +0000 Subject: 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. --- usr.sbin/pkg_add/OpenBSD/Vstat.pm | 43 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD/Vstat.pm') 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 # @@ -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; -- cgit v1.2.3