X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fthreads.c;h=33417083d2c2e4c632a5893ad0bb51046ac31130;hb=24c1359ec88d5c00e1e8376b46856519f706a440;hp=00fc0506429a9eef8c98673ab4b3e46eb0379052;hpb=95a7eaaa4a1065334125b65130866f8d1048ddb7;p=tpg%2Facess2.git diff --git a/Kernel/threads.c b/Kernel/threads.c index 00fc0506..33417083 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -3,7 +3,7 @@ * threads.c * - Common Thread Control */ -#include +#include #include #include @@ -41,8 +41,10 @@ void Threads_Wake(tThread *Thread); void Threads_AddActive(tThread *Thread); int Threads_GetPID(); int Threads_GetTID(); - int Threads_GetUID(); - int Threads_GetGID(); +tUID Threads_GetUID(); + int Threads_SetUID(Uint *Errno, tUID ID); +tGID Threads_GetGID(); + int Threads_SetGID(Uint *Errno, tUID ID); void Threads_Dump(); // === GLOBALS === @@ -616,15 +618,39 @@ int Threads_GetTID() { return Proc_GetCurThread()->TID; } -int Threads_GetUID() +tUID Threads_GetUID() { return Proc_GetCurThread()->UID; } -int Threads_GetGID() +tGID Threads_GetGID() { return Proc_GetCurThread()->GID; } +int Threads_SetUID(Uint *Errno, tUID ID) +{ + tThread *t = Proc_GetCurThread(); + if( t->UID != 0 ) { + *Errno = -EACCES; + return -1; + } + Log("Threads_SetUID - Setting User ID to %i", ID); + t->UID = ID; + return 0; +} + +int Threads_SetGID(Uint *Errno, tGID ID) +{ + tThread *t = Proc_GetCurThread(); + if( t->UID != 0 ) { + *Errno = -EACCES; + return -1; + } + Log("Threads_SetGID - Setting Group ID to %i", ID); + t->GID = ID; + return 0; +} + /** * \fn void Threads_Dump() * \brief Dums a list of currently running threads @@ -708,3 +734,6 @@ void Threads_SegFault(tVAddr Addr) Warning("Thread #%i committed a segfault at address %p", Proc_GetCurThread()->TID, Addr); Threads_Exit( 0, -1 ); } + +// === EXPORTS === +EXPORT(Threads_GetUID);