I'm a bit confused here, ERANGE is not documented as an errno value from mmap(2) both on Linux and FreeBSD. It seems that the range issue is handled with:
EINVAL We don't like addr, length, or offset (e.g., they are too large, or not aligned on a page boundary).
@Hello71, what is your kernel version here? I've checked (on kernel 4.14) and XFS doesn't seem to be returning ERANGE in the case of a mmap...
The fix lgtm; but this ERANGE thing is just weird and confusing to me from which syscall this can come. The open(), fstat() and mmap() don't seem to never return that :S ...
/** Try to create a memory mapping for <b>filename</b> and return it. On * failure, return NULL. Sets errno properly, using ERANGE to mean * "empty file". */tor_mmap_t *tor_mmap_file(const char *filename)
As per discussion on IRC, in c8ee12b2e8108658d647aedb92885311291b6f71, it would be useful to have a comment in consensus_cache_rescan() about the meaning of errno == ERANGE after calling tor_mmap_file().
I think we are generally a bit inconsistent about this, but there is an empty line at the end of changes/bug24099, but it looks like that shouldn't really matter.