tech-misc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: UFS dirent d_reclen
Date: Thu, 10 Sep 2020 11:49:21 -0400
From: Jan Schaumann <jschauma%netmeister.org@localhost>
Message-ID: <20200910154920.GZ26641%netmeister.org@localhost>
| I did think, though, that d_reclen represents what it
| says it represents: the size of this dirent.
It does. Just as Mouse said, what you receive in your buffer
is *not* what exists in the directory. 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.
| That makes sense to me in the context of the whole
| struct, but if the on-disk format disagrees, is there
| no way to determine the actual size of that particular
| dirent?
What is it you're trying to find out really there?
| Because it truly is _not_ 16, so what use is
| d_reclen if it doesn't provide me with the answer to
| the question "how large is this one directory entry"?
It allows you to find the next dirent in the buffer. That's its
purpose.
Think about it for a second, if it wasn't correct (ie: if the first
one really should have been 12, rather than 16) then how would
you be finding the d_reclen of the second one, you'd be looking
in the wrong place.
The kernel reads the directory, and sends back the info it
finds in struct dirent's that are as small as they can be
consistent with the requirements (alignment etc) of the
architecture.
There's no point returning you 400+ bytes of padding that the
kernel inserts at the end of the final directory entry in the
block, to pad it to a multiple of 512, that's just noise data,
so all of that is removed from what you get. If there was a
second directory block after that (perhaps the first one was once
full of other files, which have all since been removed) then
the first entry from the 2nd block would follow immediately after
the last one from the previos block - the only padding between
them is what is needed for alignment.
kre
Home |
Main Index |
Thread Index |
Old Index