core: Fix bug in make_file_impl() which affects directory scanning
core: Fix bug in make_file_impl() which affects directory scanning

Intention was to get file status flags, but we were instead getting
file descriptor flags, which is limited to O_CLOEXEC.

This bug broke directory scanning because append_challenged_posix_file_impl
was always used, and it doesn't work with directories. Why? It issues
::lseek(fd, 0, SEEK_END) in its constructor, and consequently getdents will
always return EOF.

Fix is about making sure that posix_file_impl is always used for directories.
fd that refers to directory will define O_RDONLY even if it wasn't passed to
open() explicitly, so test used currently is enough.

Signed-off-by: Raphael S. Carvalho <1e2942cea40e3b4d2162dfcd9e53e41c05a84d22@scylladb.com>
Message-Id: <1471459630-13707-1-git-send-email-1e2942cea40e3b4d2162dfcd9e53e41c05a84d22@scylladb.com>

kjniemi/seastar,dreamsxin/seastar,cloudius-systems/seastar,avikivity/seastar,syuu1228/seastar,cloudius-systems/seastar,kjniemi/seastar,avikivity/seastar,avikivity/seastar,scylladb/seastar,cloudius-systems/seastar,dreamsxin/seastar,scylladb/seastar,scylladb/seastar,kjniemi/seastar,dreamsxin/seastar,syuu1228/seastar,syuu1228/seastar