Skip site navigation (1)Skip section navigation (2)
Date:      1 Apr 1997 23:00:06 +0200
From:      sec@42.org (Stefan `Sec` Zehl)
To:        freebsd-hackers@freebsd.org
Subject:   Re: ftruncate("directory")...
Message-ID:  <slrn5k2tqm.3q8.sec@matrix.42.org>
References:  <Pine.NEB.3.96.970331000021.199S-100000@thelab.hub.org> <199703311832.LAA09800@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
I didn't get the original article, so i reply to this one instead :) 

> > 	Has anyone written (is it possible?) a utility that can
> > 'truncate' a directory? 
> > 
> > 	Essentially, what I'm looking at is something that would
> > open a directory, re-org the entries in it so that only the 'good'
> > entries are at the head of the file, and then truncate it...
> > 
> > 	Not sure if this is actually possible, but am going to play
> > with it here...but if its already been done, all the better... :)

Hmm, i always solved this problem by
#!/bin/sh
mkdir new_dir
cd old_dir
mv * ../new_dir
cd ..
rmdir old_dir
mv new_dir old_dir

okay, its not the nicest solution, but it works perfectly for me :) 

>                                                             For
> the amount of fragmentation necessary to achieve utility from this
> recovery, you would need to have set up a scenario terribly different
> from standard utilization patterns.  Perhaps the lmbench directory
> create/delete test?

I sometimes create a whole bunch of files (with a script) 
in a directory, and just want to keep an very few of them - so the
directory is actually much bigger than it needs to be :) 

CU,
	Sec
-- 
Fuer die Raupe ist es das Ende der Welt,
Fuer den Rest der Welt ist es ein Schmetterling
							    Error 0: No error



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?slrn5k2tqm.3q8.sec>