From 13f5e9b9830f54bde77147642aa3d468f5922546 Mon Sep 17 00:00:00 2001 From: Chirantan Ekbote Date: Tue, 9 Nov 2021 16:52:01 +0900 Subject: [PATCH] fs: Use openat64 instead of openat This ensures that we can open files whose sizes may be larger than a 32-bit off_t. BUG=b:181113648 TEST=emerge-kukui crosvm Change-Id: I2322480dcf507f83609117b4def40846d619b69b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3270100 Tested-by: kokoro Commit-Queue: Chirantan Ekbote Reviewed-by: Daniel Verkamp --- devices/src/virtio/fs/passthrough.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/devices/src/virtio/fs/passthrough.rs b/devices/src/virtio/fs/passthrough.rs index 4e714d70b8..2e839107f1 100644 --- a/devices/src/virtio/fs/passthrough.rs +++ b/devices/src/virtio/fs/passthrough.rs @@ -575,7 +575,7 @@ impl PassthroughFs { // Safe because this doesn't modify any memory and we check the return value. let raw_descriptor = syscall!(unsafe { - libc::openat( + libc::openat64( libc::AT_FDCWD, proc_cstr.as_ptr(), libc::O_PATH | libc::O_NOFOLLOW | libc::O_CLOEXEC, @@ -682,7 +682,7 @@ impl PassthroughFs { // have much bigger problems. Also, clear the `O_NOFOLLOW` flag if it is set since we need // to follow the `/proc/self/fd` symlink to get the file. let raw_descriptor = syscall!(unsafe { - libc::openat( + libc::openat64( self.proc.as_raw_descriptor(), pathname.as_ptr(), (flags | libc::O_CLOEXEC) & !(libc::O_NOFOLLOW | libc::O_DIRECT), @@ -791,7 +791,7 @@ impl PassthroughFs { // Safe because this doesn't modify any memory and we check the return value. let f = unsafe { - File::from_raw_descriptor(syscall!(libc::openat( + File::from_raw_descriptor(syscall!(libc::openat64( parent.as_raw_descriptor(), name.as_ptr(), flags @@ -1345,7 +1345,7 @@ impl FileSystem for PassthroughFs { let flags = libc::O_DIRECTORY | libc::O_NOFOLLOW | libc::O_CLOEXEC; // Safe because this doesn't modify any memory and we check the return value. - let raw_descriptor = unsafe { libc::openat(libc::AT_FDCWD, root.as_ptr(), flags) }; + let raw_descriptor = unsafe { libc::openat64(libc::AT_FDCWD, root.as_ptr(), flags) }; if raw_descriptor < 0 { return Err(io::Error::last_os_error()); } @@ -1569,7 +1569,7 @@ impl FileSystem for PassthroughFs { // Safe because this doesn't modify any memory and we check the return value. syscall!(unsafe { - libc::openat( + libc::openat64( data.as_raw_descriptor(), current_dir.as_ptr(), tmpflags, @@ -1608,7 +1608,7 @@ impl FileSystem for PassthroughFs { // really check `flags` because if the kernel can't handle poorly specified flags then // we have much bigger problems. syscall!(unsafe { - libc::openat(data.as_raw_descriptor(), name.as_ptr(), create_flags, mode) + libc::openat64(data.as_raw_descriptor(), name.as_ptr(), create_flags, mode) })? };