From owner-freebsd-questions Tue Nov 21 17:47:36 2000 Delivered-To: freebsd-questions@freebsd.org Received: from shalimar.net.au (shalimar.net.au [198.142.161.98]) by hub.freebsd.org (Postfix) with ESMTP id 19A0F37B479 for ; Tue, 21 Nov 2000 17:47:31 -0800 (PST) Received: from shalimar.net.au (localhost [127.0.0.1]) by shalimar.net.au (8.11.1/8.11.1) with SMTP id eAM1lA606940; Wed, 22 Nov 2000 12:47:14 +1100 (EST) (envelope-from count@shalimar.net.au) From: Zero Sum Organization: Tobacco Chewers and Body Painters Association. Date: Wed, 22 Nov 2000 12:47:10 +1100 X-Mailer: KMail [version 1.1.99] Content-Type: text/plain; charset="iso-8859-1" To: "Human" , "freebsdquestions" References: In-Reply-To: Subject: Re: filesystem/dir file? MIME-Version: 1.0 Message-Id: <00112212471005.05727@shalimar.net.au> Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wednesday 22 November 2000 03:36, Human wrote: > HI > > Ive tried this in SCO UW7, Redhat and FBSD 4.0. > > If u make a empty directory and then run a script in it to produce a couple > thousand empty files , u will note that the size of the actual directory > file increases, which is normal because the actual file names of the files u > have created in the dir and their inode numbers are stored in the directory > file. The strange thing is once u delete the files in the directory the size > of the directory file does NOT decrease, why??? I presume the reference to > the file is removed but it seems (im not sure about the wording) the > placeholder or buffer in the directory file does not get removed therefore > it stays the same size. > > My question is why does it not empty the file properly this seems like a > large waste of space, the only conclusion I can come to is in the old days > (b4 I was born) computers were too slow and it would have used up > unnecessary resources????? > Any one have a better theory? > It is the way directory entries work, I Unix a directory entry is just a 'link'. A two coloumn table entry containing the inode number and the file name. This is why rm does not delete anything. It hust removes the link as there may be other links. Execute permission on a directory means the ability to make the association between the two coloumns (see execute *is* appropriate). Read permission allows you to see the links in the directory (but not the files) and write allows you to modify the directory. Table entries are created as they are needed, unsorted, unordered. i.e. The directory files are grown by a block when all table entries are full. Put a lage number of files in a directory, you get a big directory. Remove a few links and you wind up with empty slots in the table, but *no adjustments are made* to the table structure, it does not "shrink". This would make for a very inefficient file system, even today. it is a maintenance function, not 'in-process' function. Directories are always read sequentially (since they are not ordered) and placing any serious number of files in a single large directory is a no-no. It can add considerably to your I/O time. I know where there is a Solaris box that takes 10 minutes to do an 'ls' of a given directory (14,000 entries). I know of no utility to shrink directories. The old technique to do this was to make a new one move the files to it, delete the old one and rename the new one. This was part of system tuning (regular maintenance) and I used to have scripts to do this. I can't see any reason why a "shrinking" utility could not be written that would shrink directories though... But I've never seen one. And it never occured to me to write one. Avoiding the problem is not too hard. Geoff -- count@shalimar.net.au Nihil curo de ista tua stulta superstitione To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message