summary refs log tree commit diff
path: root/devices/src
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
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')
-rw-r--r--devices/src/virtio/fs/fuse.rs12
-rw-r--r--devices/src/virtio/fs/passthrough.rs4
2 files changed, 8 insertions, 8 deletions
diff --git a/devices/src/virtio/fs/fuse.rs b/devices/src/virtio/fs/fuse.rs
index 0fac6e6..f9f97d8 100644
--- a/devices/src/virtio/fs/fuse.rs
+++ b/devices/src/virtio/fs/fuse.rs
@@ -654,12 +654,12 @@ impl Into<libc::stat64> for SetattrIn {
         out.st_uid = self.uid;
         out.st_gid = self.gid;
         out.st_size = self.size as i64;
-        out.st_atime = self.atime as i64;
-        out.st_mtime = self.mtime as i64;
-        out.st_ctime = self.ctime as i64;
-        out.st_atime_nsec = self.atimensec as i64;
-        out.st_mtime_nsec = self.mtimensec as i64;
-        out.st_ctime_nsec = self.ctimensec as i64;
+        out.st_atime = self.atime as libc::time_t;
+        out.st_mtime = self.mtime as libc::time_t;
+        out.st_ctime = self.ctime as libc::time_t;
+        out.st_atime_nsec = self.atimensec as libc::c_long;
+        out.st_mtime_nsec = self.mtimensec as libc::c_long;
+        out.st_ctime_nsec = self.ctimensec as libc::c_long;
 
         out
     }
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 {