With the current implementation reading the .zfs directory with getdents
or getdirentries will behave weirdly :
- First call will fill the '.' dirent info and return the number of bytes transfered
- Second call will fill the '..' dirent info and return the number of bytes transfered
- Third call will fill the 'snapshot' dirent info and return the number of bytes transfered
- Fourth call will fill again the 'snapshot' dirent info, return -1 and set errno to EINVAL
As noted in the getdents man when the end of the directory is reached a value
of 0 should be returned.
Correct the implementation by filling the buffer the 'snapshot' info only when
the fd offset is equal to the dots offset (the size of two dirent structures).
Sponsored by: Gandi.net
MFC After: 3 days