syscall: dup the argument to fdopendir
syscall: dup the argument to fdopendir

fdopendir takes ownership of its file descriptor argument.
Getdirentries shouldn't do that, so dup the file descriptor
before passing to fdopendir.

Fixes #31269

Change-Id: Ie36be8fd6c59eb339dcc9f40228d4191fc1e5850
Reviewed-on: https://go-review.googlesource.com/c/go/+/170698
Run-TryBot: Keith Randall <8c99c3a9284e493be632950b84cd789d08ed3e9d@golang.org>
Reviewed-by: Brad Fitzpatrick <ae9783c0b0efc69cd85ab025ddd17aa44cdc4aa5@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>

akutz/go,cloudflare/go,nawawi/go,golang/go,akutz/go,golang/go,akutz/go,CAFxX/go,CAFxX/go,akutz/go,nawawi/go,nawawi/go,cloudflare/go,CAFxX/go,CAFxX/go,cloudflare/go,CAFxX/go,josharian/go,golang/go,akutz/go,nawawi/go,josharian/go,CAFxX/go,josharian/go,cloudflare/go,akutz/go,cloudflare/go,nawawi/go,josharian/go,nawawi/go,josharian/go,nawawi/go,cloudflare/go,akutz/go,golang/go,josharian/go,golang/go,cloudflare/go,golang/go,CAFxX/go,golang/go,akutz/go,cloudflare/go,nawawi/go,josharian/go,golang/go,CAFxX/go,josharian/go