summaryrefslogtreecommitdiff
path: root/Userland/DevTools/UserspaceEmulator
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2022-01-11 16:51:34 +0100
committerAndreas Kling <kling@serenityos.org>2022-01-12 14:54:12 +0100
commit182016d7c0059e9cfd74124c3d732060d31f3cec (patch)
treeda1c24baf53142d00e3aee901ca858f6c6580150 /Userland/DevTools/UserspaceEmulator
parent5f71925aa42ca3c5665d66ec5ada87494ad0a885 (diff)
downloadserenity-182016d7c0059e9cfd74124c3d732060d31f3cec.zip
Kernel+LibC+LibCore+UE: Implement `fchmodat(2)`
This function is an extended version of `chmod(2)` that lets one control whether to dereference symlinks, and specify a file descriptor to a directory that will be used as the base for relative paths.
Diffstat (limited to 'Userland/DevTools/UserspaceEmulator')
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.h2
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp13
2 files changed, 10 insertions, 5 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h
index 90c4d8644f..b62f66fdd3 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator.h
+++ b/Userland/DevTools/UserspaceEmulator/Emulator.h
@@ -136,7 +136,7 @@ private:
int virt$beep();
int virt$bind(int sockfd, FlatPtr address, socklen_t address_length);
int virt$chdir(FlatPtr, size_t);
- int virt$chmod(FlatPtr, size_t, mode_t);
+ int virt$chmod(FlatPtr);
int virt$chown(FlatPtr);
int virt$clock_gettime(int, FlatPtr);
int virt$clock_nanosleep(FlatPtr);
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
index adba1a8faf..ed29cbd10d 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
@@ -52,7 +52,7 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
case SC_chdir:
return virt$chdir(arg1, arg2);
case SC_chmod:
- return virt$chmod(arg1, arg2, arg3);
+ return virt$chmod(arg1);
case SC_chown:
return virt$chown(arg1);
case SC_clock_gettime:
@@ -418,10 +418,15 @@ int Emulator::virt$dbgputstr(FlatPtr characters, int length)
return 0;
}
-int Emulator::virt$chmod(FlatPtr path_addr, size_t path_length, mode_t mode)
+int Emulator::virt$chmod(FlatPtr params_addr)
{
- auto path = mmu().copy_buffer_from_vm(path_addr, path_length);
- return syscall(SC_chmod, path.data(), path.size(), mode);
+ Syscall::SC_chmod_params params;
+ mmu().copy_from_vm(&params, params_addr, sizeof(params));
+
+ auto path = mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length);
+ params.path.characters = (char const*)path.data();
+ params.path.length = path.size();
+ return syscall(SC_chmod, &params);
}
int Emulator::virt$chown(FlatPtr params_addr)