.with_section(||libc::off_t::MAX.to_string().header("Max value of `off_t` is"))
.with_warning(||"Usually `off_t` is a signed 64 bit integer. Whereas the buffer's size is unsigned. On systems where `off_t` is 64 bits or higher, this should realistically never happen and probably indicates a bug.")?)<0{
// Error
Err(std::io::Error::last_os_error())
}else{
Ok(())
}
}.wrap_err("fallocate() failed")
.with_section(||vec.len().header("Bytes to allocate was"))
.with_suggestion(||"Make sure there is enough space for the fallocate() call")
.with_suggestion(||"Make sure we are able to write to the file")?;
// fallocate() succeeded in allocating `vec.len()` bytes to map.
letmutmap=unsafe{MmapMut::map_mut(file)}
.wrap_err(eyre!("Failed to map file for read + write"))
.with_section(||fd.header("fd was"))
.with_suggestion(||"Do we have the premissions for both reading and writing of this file and fd?")?;
// This must be `DeserializeOwned` because the lifetime it is bound to is that of the memory map created and destroyed in the function, not of the fd `file` itself.
.wrap_err(eyre!("Failed to deserialise from map"))
.with_note(||"The prealloc read and write functions handle only *uncompressed* data. Make sure you're not feeding it compressed data (written with the non-prealloc read and write functions)")