summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorBrendan Coles <bcoles@gmail.com>2021-03-16 15:39:24 +0000
committerAndreas Kling <kling@serenityos.org>2021-03-16 21:57:13 +0100
commit46c7f52896e41ee2743f2434155477852ceff8c6 (patch)
tree9fbb938057090c7be42ee37816336d82ba2f6839 /Userland
parent569d6d47fe3232c823cfbb7a24938fe309e2ab11 (diff)
downloadserenity-46c7f52896e41ee2743f2434155477852ceff8c6.zip
UserspaceEmulator: Add symlink, rename, set_coredump_metadata syscalls
Diffstat (limited to 'Userland')
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.h3
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp54
2 files changed, 57 insertions, 0 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h
index 316e5aae19..c0c3758a3e 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator.h
+++ b/Userland/DevTools/UserspaceEmulator/Emulator.h
@@ -125,6 +125,9 @@ private:
int virt$mkdir(FlatPtr path, size_t path_length, mode_t mode);
int virt$rmdir(FlatPtr path, size_t path_length);
int virt$unlink(FlatPtr path, size_t path_length);
+ int virt$symlink(FlatPtr address);
+ int virt$rename(FlatPtr address);
+ int virt$set_coredump_metadata(FlatPtr address);
int virt$get_process_name(FlatPtr buffer, int size);
int virt$set_process_name(FlatPtr buffer, int size);
int virt$set_mmap_name(FlatPtr);
diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
index ba8fe9b5ec..ef8dba7895 100644
--- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
+++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp
@@ -138,6 +138,12 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$rmdir(arg1, arg2);
case SC_unlink:
return virt$unlink(arg1, arg2);
+ case SC_symlink:
+ return virt$symlink(arg1);
+ case SC_rename:
+ return virt$rename(arg1);
+ case SC_set_coredump_metadata:
+ return virt$set_coredump_metadata(arg1);
case SC_write:
return virt$write(arg1, arg2, arg3);
case SC_read:
@@ -320,6 +326,54 @@ int Emulator::virt$unlink(FlatPtr path, size_t path_length)
return syscall(SC_unlink, buffer.data(), buffer.size());
}
+int Emulator::virt$symlink(FlatPtr params_addr)
+{
+ Syscall::SC_symlink_params params;
+ mmu().copy_from_vm(&params, params_addr, sizeof(params));
+
+ auto target = mmu().copy_buffer_from_vm((FlatPtr)params.target.characters, params.target.length);
+ params.target.characters = (const char*)target.data();
+ params.target.length = target.size();
+
+ auto link = mmu().copy_buffer_from_vm((FlatPtr)params.linkpath.characters, params.linkpath.length);
+ params.linkpath.characters = (const char*)link.data();
+ params.linkpath.length = link.size();
+
+ return syscall(SC_symlink, &params);
+}
+
+int Emulator::virt$rename(FlatPtr params_addr)
+{
+ Syscall::SC_rename_params params;
+ mmu().copy_from_vm(&params, params_addr, sizeof(params));
+
+ auto new_path = mmu().copy_buffer_from_vm((FlatPtr)params.new_path.characters, params.new_path.length);
+ params.new_path.characters = (const char*)new_path.data();
+ params.new_path.length = new_path.size();
+
+ auto old_path = mmu().copy_buffer_from_vm((FlatPtr)params.old_path.characters, params.old_path.length);
+ params.old_path.characters = (const char*)old_path.data();
+ params.old_path.length = old_path.size();
+
+ return syscall(SC_rename, &params);
+}
+
+int Emulator::virt$set_coredump_metadata(FlatPtr params_addr)
+{
+ Syscall::SC_set_coredump_metadata_params params;
+ mmu().copy_from_vm(&params, params_addr, sizeof(params));
+
+ auto key = mmu().copy_buffer_from_vm((FlatPtr)params.key.characters, params.key.length);
+ params.key.characters = (const char*)key.data();
+ params.key.length = key.size();
+
+ auto value = mmu().copy_buffer_from_vm((FlatPtr)params.value.characters, params.value.length);
+ params.value.characters = (const char*)value.data();
+ params.value.length = value.size();
+
+ return syscall(SC_set_coredump_metadata, &params);
+}
+
int Emulator::virt$dbgputstr(FlatPtr characters, int length)
{
auto buffer = mmu().copy_buffer_from_vm(characters, length);