tech-kern archive

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

Re: Directory entry parsing code has changed on NetBSD 4.0



>> As for your directory entries, [...].  (I don't understand why you
>> pad with so many more NULs than necessary, but that's not doing any
>> harm except making things more verbose.)
> Where are those NULs?

Here's the beginning of the data you posted, uudecoded and run through
hexdump -C:

00000000  02 00 00 00 00 00 00 00  14 00 01 00 04 2e 00 00  |................|
00000010  00 00 00 00 02 00 00 00  00 00 00 00 14 00 02 00  |................|
00000020  04 2e 2e 00 00 00 00 00  03 00 00 00 00 00 00 00  |................|
00000030  18 00 07 00 02 69 34 62  74 65 6c 30 00 00 00 00  |.....i4btel0....|
00000040  04 00 00 00 00 00 00 00  1c 00 08 00 02 69 34 62  |.............i4b|
00000050  74 65 6c 64 30 00 00 00  00 00 00 00 05 00 00 00  |teld0...........|
00000060  00 00 00 00 18 00 07 00  02 69 34 62 74 65 6c 31  |.........i4btel1|
00000070  00 00 00 00 06 00 00 00  00 00 00 00 1c 00 08 00  |................|

Breaking this down (assuming, as I mentioned, a little-endian machine),

d_fileno        02 00 00 00 00 00 00 00
d_reclen        14 00
d_namlen        01 00
d_type          04
d_name          2e 00 00 00 00 00 00

d_fileno        02 00 00 00 00 00 00 00
d_reclen        14 00
d_namlen        02 00
d_type          04
d_name          2e 2e 00 00 00 00 00

d_fileno        03 00 00 00 00 00 00 00
d_reclen        18 00
d_namlen        07 00
d_type          02
d_name          69 34 62 74 65 6c 30 00 00 00 00

d_fileno        04 00 00 00 00 00 00 00
d_reclen        1c 00
d_namlen        08 00
d_type          02
d_name          69 34 62 74 65 6c 64 30 00 00 00 00 00 00 00

d_fileno        05 00 00 00 00 00 00 00
d_reclen        18 00
d_namlen        07 00
d_type          02
d_name          69 34 62 74 65 6c 31 00 00 00 00

The first, second, and fourth of these have four more NULs in d_name
than they need.  It actually looks as though you're padding "at least
four NULs, plus more as needed to align on a 32-bit boundary" rather
than "at least one NUL, plus more as needed to align on a 32-bit
boundary".

However, because your d_reclen and d_namlen values account for the
padding properly, this is an efficiency issue rather than a correctness
issue.

/~\ The ASCII                           der Mouse
\ / Ribbon Campaign
 X  Against HTML               mouse%rodents.montreal.qc.ca@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index