vfs: fix errno in sendfile()

The man-page of sendfile() says to return the following on errors:

EBADF  The input file was not opened for reading or the output file was
       not opened for writing.

EINVAL Descriptor is not valid or locked, or an mmap(2)-like operation
       is not available for in_fd.

But sendfile() on Linux returns EBADF when the descriptor is not valid.
It return EINVAL when writing to the file has failed.  Change sendfile()
to behave the same as Linux.

Also, replace C style code with C++ such as using mmu::page_size instead
of PAGESIZE.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: fix tst-sendfile.cc

Fix test to expect EBADF on a bad fd.
Use std::thread to allow the test to be compiled and run on linux.
Move the setup part (socket(),bind(),listen()) of server outside the thread.

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>