sys_util: replace fallocate64 with libc call

Now that libc includes the fallocate64 function declaration that we
need, we can drop our own declaration and resolve the TODOs.

BUG=None
TEST=cargo build

Change-Id: I7548a561d672739fa7cdd7eb996ad2b2e307d69a
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1352866
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This commit is contained in:
Daniel Verkamp 2018-11-28 09:39:27 -08:00 committed by chrome-bot
parent 510c1cfb46
commit 9ae286d008

View file

@ -165,16 +165,6 @@ pub enum FallocateMode {
ZeroRange,
}
// TODO(dverkamp): Remove this once fallocate64 is available in libc.
extern "C" {
pub fn fallocate64(
fd: libc::c_int,
mode: libc::c_int,
offset: libc::off64_t,
len: libc::off64_t,
) -> libc::c_int;
}
/// Safe wrapper for `fallocate()`.
pub fn fallocate(
file: &AsRawFd,
@ -206,8 +196,7 @@ pub fn fallocate(
// Safe since we pass in a valid fd and fallocate mode, validate offset and len,
// and check the return value.
// TODO(dverkamp): Replace this with libc::fallocate64 once it is available.
let ret = unsafe { fallocate64(file.as_raw_fd(), mode, offset, len) };
let ret = unsafe { libc::fallocate64(file.as_raw_fd(), mode, offset, len) };
if ret < 0 {
errno_result()
} else {