[comp.unix.questions] Directories That Grow

pjh@mccc.uucp (Pete Holsberg) (04/10/90)

In my news directory structure, certain very active directories appear
to be growing without bound.  For example, $NEWS/in.coming is very large
but at this point contain about 4 actual files.

How can I "reset" these directories so that "leading" entries with inode
0 are removed?

Thanks,
Pete

-- 
Prof. Peter J. Holsberg      UUCP: {...!rutgers!}princeton!mccc!pjh 
Eng'g Tech'gy/Comp'r/Math    Mercer College - 1200 Old Trenton Road
Trenton, NJ 08690            Voice: 609-586-4800  FAX: 609-586-6944
Home of the 1990 TRENTON COMPUTER FESTIVAL, April 21-22, 1990

jeff@quark.WV.TEK.COM (Jeff Beadles) (04/11/90)

pjh@mccc.uucp (Pete Holsberg) writes:
>In my news directory structure, certain very active directories appear
>to be growing without bound.  For example, $NEWS/in.coming is very large
>but at this point contain about 4 actual files.
>
>How can I "reset" these directories so that "leading" entries with inode
>0 are removed?
>
>Thanks,
>Pete


Easy!  Just do this.

(Make sure that you are not receiving/processing news when you do this.)

cd $NEWS
mv in.coming in.coming.old
mkdir in.coming
chmod xxx in.coming		# Change to whatever permissions/owner the old
chown xxx in.coming		# directory had.
chgrp xxx in.coming

mv in.coming.old/* in.coming

That will work as long as there are no files that start with "." in the
directory.  If there are some (other than . and ..) you need to move them too.

In Unix, directories grow, but never shrink.  This is the only way that I know
of to do this.

Best,
	-Jeff
-- 
Jeff Beadles				jeff@quark.WV.TEK.COM 
Utek Engineering, Tektronix Inc.	+1 503 685 2568
			"Credo quia absurdum"

guy@auspex.auspex.com (Guy Harris) (04/12/90)

>In Unix, directories grow, but never shrink.

In some versions of UNIX, directories grow, but never shrink.

In some file systems in some other versions of UNIX, directories shrink
as well as grow.  The 4.3BSD file system will shrink directories; I
think SunOS 4.1 and S5R4's UFS file system include that.

donlash@uncle.UUCP (Donald Lashomb) (04/12/90)

In article <1990Apr10.002953.1233@mccc.uucp> pjh@mccc.uucp (Pete Holsberg) writes:
>In my news directory structure, certain very active directories appear
>to be growing without bound.  For example, $NEWS/in.coming is very large
>but at this point contain about 4 actual files.
>
>How can I "reset" these directories so that "leading" entries with inode
>0 are removed?

try -
	  mv $NEWS/in.coming $NEWS/in.coming-old
	  mkdir $NEWS/in.coming
	  find $NEWS/in.coming-old -print | cpio -pdlm $NEWS/in.coming

	  # if everything looks ok, then rm -r $NEWS/in.coming-old

hope this helps, but why aren't the leading 0-inode entries being
re-used automatically?  When creating a file the system is supposed
to use the first empty slot in the directory.  Only if no empty slot
is the dir extended.  That's what I believe is supposed to happen.

-Don		donlash@uncle.UUCP

stv@ferret.UUCP (Steve Manning) (04/14/90)

In article <795@uncle.UUCP> donlash@uncle.UUCP (Donald Lashomb) writes:
>In article <1990Apr10.002953.1233@mccc.uucp> pjh@mccc.uucp (Pete Holsberg) writes:
>>In my news directory structure, certain very active directories appear
>>to be growing without bound.  For example, $NEWS/in.coming is very large
>>but at this point contain about 4 actual files.
>>
>>How can I "reset" these directories so that "leading" entries with inode
>>0 are removed?
>
>try -
>	  mv $NEWS/in.coming $NEWS/in.coming-old
>	  mkdir $NEWS/in.coming
>	  find $NEWS/in.coming-old -print | cpio -pdlm $NEWS/in.coming

This isn't quite right.  The "find" command line should be replaced by:

	  cd $NEWS/in.coming-old
	  find . -print | cpio -pdlm $NEWS/in.coming

Otherwise the entire $NEWS/in.coming-old heirarchy will be recreated under
$NEWS/in.coming, so that you end up with paths of:

	$NEWS/in.coming$NEWS/in.coming-old/somefile
	
rather than grafting what is _under_ $NEWS/in.coming-old across to
$NEWS/in.coming.

At least, that's how it works on the versions that I use.  Is there another
way to accomplish this?
-----