1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 22:25:07 +00:00

Kernel: Add a Linux-style getrandom syscall

The way it gets the entropy and blasts it to the buffer is pretty
ugly IMHO, but it does work for now. (It should be replaced, by
not truncating a u32.)

It implements an (unused for now) flags argument, like Linux but
instead of OpenBSD's. This is in case we want to distinguish
between entropy sources or any other reason and have to implement
a new syscall later. Of course, learn from Linux's struggles with
entropy sourcing too.
This commit is contained in:
Calvin Buckley 2019-10-13 11:41:55 -03:00 committed by Andreas Kling
parent 0e61d84749
commit 7e4e092653
4 changed files with 26 additions and 1 deletions

View file

@ -313,6 +313,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
return current->process().sys$get_process_name((char*)arg1, (int)arg2);
case Syscall::SC_realpath:
return current->process().sys$realpath((const char*)arg1, (char*)arg2, (size_t)arg3);
case Syscall::SC_getrandom:
return current->process().sys$getrandom((void*)arg1, (size_t)arg2, (unsigned int)arg3);
default:
kprintf("<%u> int0x82: Unknown function %u requested {%x, %x, %x}\n", current->process().pid(), function, arg1, arg2, arg3);
return -ENOSYS;