Samba needs limited seekdir() functionality to work when files have been deleted from the directory during the session. It only needs to be able to back up a single entry when it finds that the directory entries it has already read have filled up its buffer and the next one won't fit. Currently this doesn't work.
Unfortunately the windows client is using these entries to delete files, so when
Samba comes back to read the entry again for the next iteration, the current seekdir() code does the
wrong thing, as the directory has been altered.
This change makes use of the fact that the previous returned item is ALWAYS still in the buffer at the time of the seek back, and this allows us to reliably fetch it again even though the directory has changed.
P.S. This is my first phabricator submission so it may look a bit unpracticed.