Messages in this thread | | | Date | Tue, 14 Jul 1998 23:33:50 +0200 (MEST) | From | Clifford Wolf <> | Subject | Re: ext2fs: do directories ever shrink? |
| |
On Mon, 13 Jul 1998, Alex Buell wrote:
> Clifford Wolf wrote: > > > A general behaviour with UNIX files is that a file can never shrink! A > > file can be trucated - but it can shrink e.g. from 10 bytes to 5. Since > > a directory is just a file it can't shrink too (except the implementation > > contains additional code for it). > > I don't understand this; are you saying that files can shrink or not? > What on earth does the directory as a file fills up with anyway? [The > largest directory size I've seen is 40,000 blocks for a directory filled > up with images and then these images were deleted!) Clearly there is a > benefit of reclaiming this - any chance the fsck process can > automatically reclaim this on reboots?
uups - a typo: a file can't shrink.
On does not need to modify fsck to "shrink" directories at boot time - this shell script should do the job (i've not tested it now and it's not perfect - but it shows the basic idea):
find / -type d -fstype ext2 | while read dirname do mkdir $dirname.new_version mv $dirname/* $dirname.new_version/ rmdir $dirname mv $dirname.new_version $dirname done
One of the problems with this script is that it does not preserve the permissions of the directories. The fact that it creates new directories with new inode numbers shouldn't be a problem since it is started at boot time.
It is easier to preserve the permissions useing a little C-Programm.
- clifford
-- -- -- -- -- -- -- -- -- -- -- -- -- Clifford Wolf magnet - Internet at Work IRC: efnet / clifford Director of System Development http://www.clifford.at/ e-mail: c.wolf@magnet.at email: god@clifford.at
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html
| |