In a recent thread, someone asked how to know how much of a directory is used; that is, information similar to "df" but for a specific directory.
Of course it's a silly question in some respects. Did he mean the percentage of file space used by this directory relative to that available on the file system? Or the number of files that exist as a percentage of the maximum number that could be created? We don't usually concern ourselves with either of those things, so there are no tools that output anything like that.
But there are limits to directories, of course. For one thing, a directory is a file like any other file, and therefore is limited in size by whatever restraints the file system puts upon it. It probably has some minimum space for the name part of its entry, and a fixed space for the inode part, so you couldn't possibly have more entries than could fit in the maximum file size. Also, there are inode limits imposed by the filesystem: if the directory could theoretically hold some impossibly large number of files, it might be impossible for that many files to exist on the file system. Not the directory's fault, of course, but still a limit.
Every file system is going to impose some limit on the maximum number of files in a directory, and may impose a different limit on files with special needs like directories (because of the links that need to be kept track of). Nowadays those limits may be very large, but they do exist.
And then we have other limits. Some file systems use a hash for file names, and are going to run into unavoidable collisions at some point that may be much smaller than any other design criteria. The Reiser FAQ currently says that it allows almost 4GB of files in a directory, but:
in practice this value is limited by hash function. r5 hash allows about 1 200 000 file names without collisions
That's more than enough entries for me, thanks.
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2009-12-15 Anthony Lawrence