>>> I want to know if there is any significant reason why the
>>> size of each directory ( ext2fs) is reported as 1024b ( or a
>>> multiple of 1024).
>>
>> Because this is the "block size" of the filesystem, the directory
>> space is allocated in units of this.
> One could say the same for regular files, so this doen't really
> explain why directory sizes are poorly reported.
What's "correct size" for directory ? If I have 1MiB directory where ls will
work few minutes but with only two entries in it ("." and "..") -- what's
the size of this directory ? 16 bytes or 1MiB ? You can create such beast
easily: just create few thousands of files in one directory and then remove
all of them.
> We do have linear directories that grow from beginning to end.
Not always. HPFS and NTFS use B-trees and there are plans to do it in ext2fs
as well...
> An empty directory is something like 16 bytes for "." and "..".
Not always (see above).
> The kernel might as well report the fact, just as it reports a
> regular file by actual content.
Regular file does not have unused space in the middle of file (from filesystem
viewpoint that is).
> If inaccurate reporting really is OK, then it might as well be
> derived from the block count. That gives an extra 4 bytes in the
> inode for directories.
-
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.tux.org/lkml/