diff --git a/quotacheck/GNUmakefile b/quotacheck/GNUmakefile index 8a93bb6..0d33c09 100644 --- a/quotacheck/GNUmakefile +++ b/quotacheck/GNUmakefile @@ -10,6 +10,7 @@ distclean: clean rm -f customize install: $(SBINDIR) $(SBINDIR)/quotacheck $(SBINDIR)/quotastat \ + $(SBINDIR)/dfree \ $(SBINDIR)/quotasanitycheck $(MAN8DIR)/quotasanitycheck.8 %: %.pl customize diff --git a/quotacheck/dfree b/quotacheck/dfree new file mode 100755 index 0000000..cee9b61 --- /dev/null +++ b/quotacheck/dfree @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# +# dfree - samba helper script for soft quota aware disk free stats +# +# Portability: HP-UX specific. + + +# send log file to /dev/null unless we want to debug this script. +umask(0077); +open (LOG, ">/dev/null") or die; +print LOG "$< $>\n"; + +# who am I? +$logname = getpwuid($>); +print LOG "$logname\n"; + +# where am I? + +open (BDF, "/bin/bdf \"${ARGV[0]}\"|") or die; +while () { + chomp; + @x = split; + $thismount = $x[-1]; + $total = $x[-5]; + $avail = $x[-3]; +} +close (BDF); +print LOG "$thismount\n"; + + + + +open (QUOTA, "/bin/quota -v $logname|") or die; +while() { + chomp; + if (m|^/\S+$|) { + $mount = $_; + } elsif (m|^\s+|) { + ($usage, $quota) = split; + if ($mount eq $thismount) { + print $quota, " ", $quota - $usage, "\n"; + print LOG $quota, $quota - $usage; + exit 0; + } + } elsif (m|/(\S+)\s+(\d+)\s+(\d+)|) { + $mount = $1; + $usage = $2; + $quota = $3; + if ($mount eq $thismount) { + print $quota, " ", $quota - $usage, "\n"; + print LOG $quota, $quota - $usage; + exit 0; + } + } +} +close (QUOTA); + +print "$total $avail\n"; +close (LOG);