I-node counter???

Donald Nichols ceilidh!dnichols at uunet.uu.net
Sun Oct 14 05:38:38 AEST 1990


"Rusty Carruth says:"
> 
> Quick question:  We have run out of inodes on one of our directories
> (the news one, of course!), and I've decided it would be real nice
> if we had a way to find out how many inodes are being used, that
> is I'd like to say something like "du -i" and get an inode report
> rather than (or along with) a block report.
> 

	How about df(1).  On most systems that I have encountered, there is
at least an option to find out how many inodes are free, and usually the
total allocated as well.  Here is the output on my unix-pc (SysVr2 - more or
less :-)

#df
/         (/dev/fp002):    14772 blocks    9231 i-nodes
#df -t
/         (/dev/fp002):    14772 blocks    9231 i-nodes
                 total:   111184 blocks   13888 i-nodes
  This is similar to the one in old v7 unix.  BSD tends to tell you the
number of k instead of the number of blocks in file space, but still tells
you the number of inodes.

 [...]
> Anyone have such a program?  Or will I have to write it myself?  (urgh, yet
> another "future project" - current future project list extends well into
> the next millenium! :-(     )

	If you just want an on-screen display, the above 'df' gives it.  If
you want to find out from within a program, pipe the output of 'df' into
your program, and extract the relevant fields.  (I won't try to give you
code, since the output format of 'df' varies so much.  Just examine your own
and write the code.)  It is a lot easer than having to open the superblock
of the raw device and look for values (which might be out of date - or is
superblock update write-through?), or open /dev/kmem and look at the
in-memory copy (which should be up to date).  Df(1) can be used without
having to relax the permissions on your raw device or /dev/kmem, and without
having to make your program set[ug]id, so you don't have to worry (as much)
about creating security holes with your program.

> Thanks!
> 
> 
> -- 
> ......
> Rusty Carruth               {ames!ncar!noao!asuvax,mcdphx}!anasaz!rusty
> P.O. Box 27001, Tempe, AZ 85285         anasaz!rusty at asuvax.eas.asu.edu
> Join the Usenet Un-Net on 10M, saturdays, time to be announced later...
> 

	Good Luck
		DoN.

-- 
Donald Nichols (DoN.)		| Voice (Days):	(703) 664-1585
D&D Data			| Voice (Eves):	(703) 938-4564
Disclaimer: from here - None	| Email:	<dnichols at ceilidh.beartrack.com>
	--- Black Holes are where God is dividing by zero ---



More information about the Comp.unix.internals mailing list