freebsd network compat layer:  fix for hrev45146

* MTX_DEF is the default type: it shouldn't be tested against but used
  as the default type.
Drop in unmodified fts/ftw implementations from FreeBSD HEAD (r245067).
Add Haiku support.

This replaces the use of a few BSD-specific functions, as well
as the direct references to _open/_close et-al.

BFS doesn't support the FTS_NOSTAT directory link count optimization,
and no statfs() function is available, so we simply turn that off.
Restore FTS_WHITEOUT, guard it with __HAIKU__.

As per Jérôme Duval's code review in issue #9337.