tech-misc archive

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

Re: UFS dirent d_reclen



Robert Elz <kre%munnari.OZ.AU@localhost> wrote:
 
> It does.   Just as Mouse said, what you receive in your buffer
> is *not* what exists in the directory.

Right - that difference didn't seem obvious to me.

> You hexdump'd the directory, what you should be
> doing is a hexdump of your buffer, and in that, I
> expect you will find that all 3 dirent's are in fact
> 16 bytes long.

Confirmed.

> What is it you're trying to find out really there?

Well, it all started with me looking at how directory
sizes increase, like so:

mkdir d
cd d
jot 40 3 | xargs touch

Now I have 42 entries here ('.', '..', and 3 - 42).
The directory size is still 512.

If I then

touch 43

the directory size increases to 1024, because the 43
directory entries do not fit into 512 bytes.

So I thought that the sum of all d_reclen's of all the
entries ought to add up to <= current directory size;
when printing d_reclen, I got 16 for each, but 42
* 16 > 512.

Your and mouse's emails helped me clarify the
difference between the dirent struct tied to the
directory as used internally versus what readdir(2)
returns (and which may then be aligned).

Thanks!
-Jan


Home | Main Index | Thread Index | Old Index