Make fileno() builtin work on directory handles

This requires OS support in the form of either the dirfd() function, or a
dd_fd member in the DIR struct. POSIX.1-2008 specifies the former. If
neither is available, fileno() on a directory handle will return undef and
set errno.