-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File offsets should be u64, not usize #65
Conversation
The appveyor failure doesn't look related to anything I touched. |
I was similarly wondering why I'm converting offset/len to usize (and asserting values are not beyond |
Well, its understandable that mapping length is limited to usize because it is memory addressable. However it would be more ergonomic, and I wonder if internally cleaner, if all offsets and sizes were u64 and the lengths checked and truncated before making the OS calls? I imagine most people are starting with u64 file offset values, to compute offset and length. |
@dekellum How do you index a |
You don't and I understand that, thanks. I still suspect most people mapping a |
let ptr = libc::mmap(
ptr::null_mut(),
aligned_len as libc::size_t,
prot,
flags,
file,
aligned_offset as libc::off_t,
); Note that the offset is cast there into a |
Some Linux man page extracts related to large files on 32-bit platforms below. This is clearly complex enough that it would be helpful if an memmap crate abstracted over it, rather than every application. If the rust API consistently used u64, and explicit checked for exceeding each platforms actual limit before truncating, raising a clear error that could be handled by the application, would that not be an improvement in the majority of use cases? Rust "std::fs::Metadata::len" returns Old rust discussion with many additional links: https://internals.rust-lang.org/t/pre-rfc-rust-and-large-file-support-lfs/2777 (2015-10) Linux man
Linux man
LFS was the Large File Summit of X/Open. See also mmap64(3). |
Yeah papering over these details would be nice. It looks like |
I've merged the PR with light edits as part of #71, since I think @dekellum and @oconnor663, I agree there are potential issues lurking here, especially on 32-bit systems and/or those where |
This should address one of the concerns that came up in danburkert#65.
This is a breaking change, but both
mmap
andMapViewOfFile
support 64 bit offsets, even on 32bit programs.