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.
This was discovered when virtiofsd users noticed that adding a memory object in QEMU backed by a device (i.e. /dev/kvmfr0) would cause the daemon to fail with Waiting for daemon failed: HandleRequest(ReqHandlerError(Custom { kind: Other, error: MappingPastEof })) (issue 46).
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 usingstd::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.This was discovered when virtiofsd users noticed that adding a memory object in QEMU backed by a device (i.e.
/dev/kvmfr0
) would cause the daemon to fail withWaiting for daemon failed: HandleRequest(ReqHandlerError(Custom { kind: Other, error: MappingPastEof }))
(issue 46).