When opening directories, don't follow symlinks

Summary:
Depends on D903726.

There has been at least one instance of a bug where watchman has decided to traverse a symlink. It is likely that this is a TOCTOU bug between checking that it's a symlink and actually
opening the directory. To deal with that, use a combination of `open` with `O_NOFOLLOW` and `fdopendir`.

Also fix up the handling for when the target is indeed a symlink.

Test Plan: `arc unit --everything` and the Mercurial test suite with `-j32`. This is a relatively obscure race, so it's hard to write a test specifically for this.

Reviewers: wez

Reviewed By: wez

Differential Revision: https://phabricator.fb.com/D903841

--HG--
extra : rebase_source : fc83622e4806ac8a87751c695b3d45f63f6f06ca
extra : amend_source : 89a8390452bc207bfc9d92d2c1c8211fd8eaf357