From owner-freebsd-hackers Tue Apr 1 13:00:23 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id NAA29973 for hackers-outgoing; Tue, 1 Apr 1997 13:00:23 -0800 (PST) Received: from matrix.42.org (sec@matrix.42.org [192.68.213.129]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id NAA29957 for ; Tue, 1 Apr 1997 13:00:16 -0800 (PST) Received: (from sec@localhost) by matrix.42.org (8.6.12/8.6.12) id XAA04589; Tue, 1 Apr 1997 23:00:08 +0200 To: freebsd-hackers@freebsd.org Path: sec From: sec@42.org (Stefan `Sec` Zehl) Newsgroups: muc.lists.freebsd.hackers Subject: Re: ftruncate("directory")... Date: 1 Apr 1997 23:00:06 +0200 Organization: Internet@home Lines: 39 Message-ID: References: <199703311832.LAA09800@phaeton.artisoft.com> X-Newsreader: slrn (0.9.3.0-2 BETA UNIX) Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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