Make dir a normal fd.

fdopendir() takes ownership of the passed fd and thus dir was being closed twice.

Change-Id: I183a1b7031d7a20bb280ce17ac94a2a0ea9a8228