summary refs log tree commit diff
path: root/devices/src/virtio/fs/passthrough.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-11-05 13:48:04 -0800
committerCommit Bot <commit-bot@chromium.org>2019-11-06 18:31:05 +0000
commit7b4822aa382da58b6a797fa617bb833a8edd6abc (patch)
tree85ccdb5c4bd1ece8004b539573eaa8009a959a4e /devices/src/virtio/fs/passthrough.rs
parent1104a730a764633e6590488b31fa801f99512c3c (diff)
downloadcrosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar.gz
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar.bz2
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar.lz
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar.xz
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.tar.zst
crosvm-7b4822aa382da58b6a797fa617bb833a8edd6abc.zip
devices: fix fuse compilation on 32-bit platforms
struct stat64 uses different types on 32-bit platforms like arm; cast to
the types used there to allow compilation on both x86-64 and arm.

In addition, a 64-bit offset was being passed to libc::ftruncate, but
this API takes a 32-bit off_t on 32-bit platforms; switch to ftruncate64
to allow the full range of offsets.

BUG=b:136128319
TEST=emerge-kevin crosvm
TEST=emerge-nami crosvm

Change-Id: I382aef8509ca723efcf5024b22e140265636dc10
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1899218
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'devices/src/virtio/fs/passthrough.rs')
-rw-r--r--devices/src/virtio/fs/passthrough.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/devices/src/virtio/fs/passthrough.rs b/devices/src/virtio/fs/passthrough.rs
index c42b212..73e7e8b 100644
--- a/devices/src/virtio/fs/passthrough.rs
+++ b/devices/src/virtio/fs/passthrough.rs
@@ -1005,11 +1005,11 @@ impl FileSystem for PassthroughFs {
         if valid.contains(SetattrValid::SIZE) {
             // Safe because this doesn't modify any memory and we check the return value.
             let res = match data {
-                Data::Handle(_, fd) => unsafe { libc::ftruncate(fd, attr.st_size) },
+                Data::Handle(_, fd) => unsafe { libc::ftruncate64(fd, attr.st_size) },
                 _ => {
                     // There is no `ftruncateat` so we need to get a new fd and truncate it.
                     let f = self.open_inode(inode, libc::O_NONBLOCK | libc::O_RDWR)?;
-                    unsafe { libc::ftruncate(f.as_raw_fd(), attr.st_size) }
+                    unsafe { libc::ftruncate64(f.as_raw_fd(), attr.st_size) }
                 }
             };
             if res < 0 {