diff options
author | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
commit | a5c52c00c16be69e14360222520129d30f76e042 (patch) | |
tree | d44ff9f87b2985ead827c72c55b5aaee23c5dd10 /mageia/usr/bin/partmon.pl | |
parent | 817ca842f086f7290f183720539834263c2f1afe (diff) | |
download | initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.gz initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.bz2 initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.xz initscripts-a5c52c00c16be69e14360222520129d30f76e042.zip |
Align Makefile and tree structure with upstream tree structure
Instead of placing the custom files with the upstream files it seems
clearer to have them mostly separated. This makes it easier to see which
parts are custom and which parts are more or less upstream.
As a result the upstream Makefile only needed minor changes to
accomodate this. The Makefile is NOT bug free, unfortunately it doesn't
always do the right thing, this due to inexperience.
Diffstat (limited to 'mageia/usr/bin/partmon.pl')
-rw-r--r-- | mageia/usr/bin/partmon.pl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/mageia/usr/bin/partmon.pl b/mageia/usr/bin/partmon.pl new file mode 100644 index 00000000..d6d297b6 --- /dev/null +++ b/mageia/usr/bin/partmon.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau (gc@mandriva.com) +# +# Copyright 2002 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +#use strict; +use MDK::Common; + +my ($verbose); + +sub free_space { + my ($mntpoint) = @_; + my ($blocksize, $size, $avail); + my $buf = ' ' x 20000; + syscall_('statfs', $mntpoint, $buf) or return; + (undef, $blocksize, $size, undef, $avail, undef) = unpack "L!6", $buf; + return $avail * ($blocksize / 1024); +} + +my %partlimits = map { if_(/^(.*\S)(?:\s+?)(\d+)$/, $1 => $2 ) } cat_('/etc/sysconfig/partmon'); + + +my $params = join '', @ARGV; + +$params =~ /-h/ and die "usage: partmon [-v]\n"; +$params =~ /-v/ and $verbose = 1; + + +my $ok = 1; +foreach (cat_('/etc/fstab')) { + /^\s*#/ and next; + my (undef, $mountpoint, undef, undef, undef, undef) = split or next; #- I want at least 6 fields to consider it a valid entry + member($mountpoint, keys %partlimits) or next; + my $free = free_space($mountpoint); + $verbose and print "Free space of <$mountpoint> is <$free>\n"; + if ($free < $partlimits{$mountpoint}) { + print "Warning, free space for <$mountpoint> is only <", free_space($mountpoint), "> (which is inferior to <$partlimits{$mountpoint}>\n"; + $ok = 0; + } +} + +$ok or exit -1; + + +#------------------------------------------------- +#- $Log$ +#- Revision 1.3 2006/05/11 12:45:38 tvignaud +#- more s/Mandrakesoft/mandriva/ +#- +#- Revision 1.2 2002/01/15 13:45:24 chmouel +#- Fix warnings. +#- +#- Revision 1.1 2002/01/15 13:44:15 chmouel +#- Add partition monitor from GC +#- |