Currently mmap::check_file_offset attempts to validate the backing
object by checking, among other things, its size to confirm the
mapping will fit on it. This check is implemented by using
std::fs::metadata to obtain the file size, but this approach doesn't
work when the backing object is a block or char device, as the
returned value is always zero.
In this commit, we replace the use of std::fs:metadata with
std::io::Seek::seek(SeekEnd(0)), which works fine even with special
files such as block and char devices. As a reference, this is the
method that QEMU uses for the same goal.
Currently mmap::check_file_offset attempts to validate the backing object by checking, among other things, its size to confirm the mapping will fit on it. This check is implemented by using std::fs::metadata to obtain the file size, but this approach doesn't work when the backing object is a block or char device, as the returned value is always zero.
In this commit, we replace the use of std::fs:metadata with std::io::Seek::seek(SeekEnd(0)), which works fine even with special files such as block and char devices. As a reference, this is the method that QEMU uses for the same goal.
Fixes: #195 Signed-off-by: Sergio Lopez slp@redhat.com