[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: e2fsck

* Ian Eure <ieure@crosssound.narrows.com>
| On a similar topic, what do directory sizes mean? I can't seem to see
| any direct
| connection between the size of a directory in an ls -l and it's contents,
| or the
| size of it's contents.

A directory is internally just like any other file. Tha data it contains
is just pairs of (filename, inode). So if a dir contains five files
these files can be anywhere on the disk, but in the file that is the
dir there will be five pairs of filenames and inodes. This way, when
a file from this directory is requested, the filesystem finds out the inode
number of the file, and can therefore locate it.

In the old days of UNIX you could actually change a directory with
an editor. This was the "cool" way to remove files :-) AFAIK this is no
longer allowed in Linux without special syscalls.

Interesting information of some relevance: How can a dir find it's name?
A directory does not store it's name, so it's not that easy. However,
it has two special files "." and "..", meaning current dir and parent
dir respectively. What it does is to look up the inode number of ".".
This is the inode number of this directory(file). Then in finds the
inode number of ".." to get it's parent. "My parent must surely know my name".
The parent does indeed know the name of all it's subdirs, but how do we
know which one this is? Well, we have it's inode number ("."). We can search
through the parents list of (filename, inode) to find the entry with
correct inode. Then we can just pull out the name too, and we're done.

Ian: As for your question; directories are just files and their sizes
are just the sizes of these files. The directory files however grow
in steps (of 1024 ?). Small dirs will (typically) have a size 1024
while dirs with many files in must have a bigger size to keep
all the (filename, inode) pairs. This means that there is no
connection between a dirs size and the size of it's contents (the files
in a dir are *not* contained in that dir physically) but a connection
(although not direct) between the size of a dir and the *number* of files
it contains.


Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

Reply to: