diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-03-23 20:37:55 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-23 19:56:13 +0100 |
commit | 0deb0c689108089b8fdda27121a8c33305394128 (patch) | |
tree | 294651c2f035e9d2e03f532061f569241d6fc22a /Userland/DevTools | |
parent | 663dea4a609faa50d484ec3d106015bf7da53bff (diff) | |
download | serenity-0deb0c689108089b8fdda27121a8c33305394128.zip |
UserspaceEmulator: Update virt$lseek and virt$ftruncate for 64bit off_t
The syscalls' prototypes were recently changed in preparation for 64bit
storage in serenity, so update them here as well :^)
Diffstat (limited to 'Userland/DevTools')
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/Emulator.h | 4 | ||||
-rw-r--r-- | Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index 7f9976d851..35ad2ee7e5 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -148,7 +148,7 @@ private: u32 virt$fcntl(int fd, int, u32); int virt$getgroups(ssize_t count, FlatPtr); int virt$setgroups(ssize_t count, FlatPtr); - int virt$lseek(int fd, off_t offset, int whence); + int virt$lseek(int fd, FlatPtr offset_addr, int whence); int virt$socket(int, int, int); int virt$getsockopt(FlatPtr); int virt$setsockopt(FlatPtr); @@ -184,7 +184,7 @@ private: u32 virt$allocate_tls(size_t); int virt$ptsname(int fd, FlatPtr buffer, size_t buffer_size); int virt$beep(); - int virt$ftruncate(int fd, off_t); + int virt$ftruncate(int fd, FlatPtr length_addr); mode_t virt$umask(mode_t); int virt$anon_create(size_t, int); int virt$recvfd(int, int); diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index 9fc50f8bcb..61724c26bd 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -457,9 +457,11 @@ int Emulator::virt$get_stack_bounds(FlatPtr base, FlatPtr size) return 0; } -int Emulator::virt$ftruncate(int fd, off_t length) +int Emulator::virt$ftruncate(int fd, FlatPtr length_addr) { - return syscall(SC_ftruncate, fd, length); + off_t length; + mmu().copy_from_vm(&length, length_addr, sizeof(off_t)); + return syscall(SC_ftruncate, fd, &length); } mode_t Emulator::virt$umask(mode_t mask) @@ -578,9 +580,13 @@ int Emulator::virt$set_process_name(FlatPtr user_buffer, int size) return syscall(SC_set_process_name, name.characters(), name.length()); } -int Emulator::virt$lseek(int fd, off_t offset, int whence) +int Emulator::virt$lseek(int fd, FlatPtr offset_addr, int whence) { - return syscall(SC_lseek, fd, offset, whence); + off_t offset; + mmu().copy_from_vm(&offset, offset_addr, sizeof(off_t)); + auto rc = syscall(SC_lseek, fd, &offset, whence); + mmu().copy_to_vm(offset_addr, &offset, sizeof(off_t)); + return rc; } int Emulator::virt$socket(int domain, int type, int protocol) |