mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
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>
This commit is contained in:
parent
1104a730a7
commit
7b4822aa38
2 changed files with 8 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue