The test was failing (after hanging for several hours) because of a
hard-coded assumption about which file descriptor would be returned
by memfd_create(). The actual file descriptor gets printed by the
test program though, so read this and use it instead. (Adjust the
test program so that this is not printed until the file is ready.)
Resolve compiler warnings about implicit function declarations, by
using the #include statements listed in the kernel.org man-pages.