1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

UserspaceEmulator: Implement chown

Now we can run 'ue chown anon ReadMe.md' :^)
This commit is contained in:
Ben Wiederhake 2021-01-23 15:45:51 +01:00 committed by Andreas Kling
parent b0b8953ec1
commit 792fa9f9fd
2 changed files with 15 additions and 0 deletions

View file

@ -529,6 +529,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$ftruncate(arg1, arg2);
case SC_umask:
return virt$umask(arg1);
case SC_chown:
return virt$chown(arg1);
default:
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function);
dump_backtrace();
@ -611,6 +613,18 @@ int Emulator::virt$chmod(FlatPtr path_addr, size_t path_length, mode_t mode)
return syscall(SC_chmod, path.data(), path.size(), mode);
}
int Emulator::virt$chown(FlatPtr params_addr)
{
Syscall::SC_chown_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 = (const char*)path.data();
params.path.length = path.size();
return syscall(SC_chown, &params);
}
int Emulator::virt$fchmod(int fd, mode_t mode)
{
return syscall(SC_fchmod, fd, mode);