Fix device_block_size_fd and fix EINVAL for read when using DIRECT_IO
This patch is for issue https://gitlab.com/cryptsetup/cryptsetup/issues/287
This patch addresses:
- fix device_block_size_fd to return block size correctly incase of files.
Also in case of 4k sector size, when opening files in O_DIRECT mode, proceeded by lseek of value which is not aligned to 4k size and read fails with EINVAL.
Adding a viable patch which does:
- In case of block device, check if lseek value is multiple of sector size ( using ioctl ) , else unset device->o_direct
- In case of files, lseek and perform a device_read_test to make sure direct_io works, else unset device->o_direct
Signed-off-by: Athira Rajeevatrajeev@linux.vnet.ibm.com