[alt.sources] Expire by inodes

scott@zorch.SF-Bay.ORG (Scott Hazen Mueller) (08/29/89)

Like some systems, I have a hard limit on the number of inodes per filesystem.
Unlike BSD-based filesystems, I can't tweak ncpg and nbpi to get more inodes.
So, I have been manually tracking the inode usage on my news spool directory
and adjusting expire intervals by hand.  The little program below takes the
total number of inodes in the filesystem, the current free inode count, and
a number representing inodes consumed per day and calculates the number of
days flag for expire.

The error-checking stinks, the comments are a little out of line with the
code, but what the heck, this is what alt.sources is for...  :-)

#include <stdio.h>
main( argc, argv )
int argc;
char *argv[];
{
long total, free, yday, change, flow, over;

total = atol( argv[1] );        /* total inodes */
free = atol( argv[2] );         /* ifree */
yday = atol( argv[3] );         /* got this many files yesterday */
change = ( yday*2 ) - free;     /* how many files to delete to get to free? */
/* Find out how many days of news are on the system if all news came in at
the rate it came in yesterday. */
flow = ( total-free )/yday;
/* The change from yesterday represents some number of days adjustment to
the total amount of news.  That is, convert the number of files that have to
be added or deleted into a number of days of flow. */
over = change/yday;
/* Output a number representing the number of days at the current flow rate
that news can be kept on the system. */
printf( "%ld\n", flow-over );
}

-- 
Scott Hazen Mueller| scott@zorch.SF-Bay.ORG (ames|pyramid|vsi1)!zorch!scott
685 Balfour Drive  | (408) 298-6213   |Mail to fusion-request@zorch.SF-Bay.ORG
San Jose, CA 95111 |No room for quote.|for sci.physics.fusion digests via email