1 // Copyright 2018 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 //! This module exposes Linux's off64_t, pread*64, and pwrite*64 identifiers as the non-64 POSIX 6 //! versions, similar to defining _FILE_OFFSET_BITS=64 in a C program. 7 8 use std::fs::File; 9 use std::io::Error; 10 use std::io::Result; 11 12 use super::fallocate; 13 use super::FallocateMode; 14 use crate::FileAllocate; 15 16 impl FileAllocate for File { allocate(&self, offset: u64, len: u64) -> Result<()>17 fn allocate(&self, offset: u64, len: u64) -> Result<()> { 18 fallocate(self, FallocateMode::Allocate, offset, len) 19 .map_err(|e| Error::from_raw_os_error(e.errno())) 20 } 21 } 22 23 // This module allows the macros in unix/file_traits.rsto refer to $crate::platform::X and ensures 24 // other crates don't need to add additional crates to their Cargo.toml. 25 pub mod lib { 26 pub use libc::off64_t as off_t; 27 pub use libc::pread64 as pread; 28 pub use libc::preadv64 as preadv; 29 pub use libc::pwrite64 as pwrite; 30 pub use libc::pwritev64 as pwritev; 31 } 32