bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New features for DF


From: John McKerrell
Subject: New features for DF
Date: 18 May 2002 14:08:57 +0000

Hi,
   I thought that df should have an option to only output partitions
that are full, handy for maintenance without having to write something
to parse the output for df. I've modified the source for df to do this
but I also thought a --no-header option would be handy. With this you
can put 'df --no-header --only-full' into a cronjob and the output will
be mailed to you if your disks are full. I've realised that I've
possibly used an old version of df.c (the one that came with Redhat 7.2,
so not too old) and one or both of these features may already be in. So,
not sure what I should do about this so I thought I'd mail this address
and see what happens, I've included a diff between my df.c and the
original together with both df.c files for context and I'll give a quick
rundown of what I've done below.
Hope you don't think it was pointless, look forward to your reply :)
John McKerrell

Quick Rundown:
Firstly, the --only-full option. It is only a long option and it takes
an optional argument, being the integer percentage that the drive must
be equal to or over in (integer) percentage size to show up in the list.
I added a global variable - show_percentage_filled - that is -1 by
default (i.e. show all, even negative percentage). I've added handling
for the long option --only-full that if optval is null it sets
show_percentage_filled to 100, otherwise show_percentage_filled is the
gets the value of atoi(optval)
The main change is in show_dev, I've moved all the print code together,
and after the point where pct gets set, I've then added a line in
between simply saying that if pct is less than show_percentage_filled,
then return - not showing this line.
For --no-header I've added a global variable - no_header - it's 0 by
default and 1 if either --no-header or -N have been passed. This value
is then checked at the beginning of print_header and if it's positive
then we simply return, outputting nothing.
I understand that some of my names might need changing or whatever, just
let me know.

Attachment: df.c.orig
Description: Text document

Attachment: df.diff
Description: Text document

Attachment: df.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]