]> git.corax.cc Git - corax/commitdiff
Add some methods for process_t types:
authorMatthias Kruk <m@m10k.eu>
Wed, 13 Nov 2019 07:35:01 +0000 (16:35 +0900)
committerMatthias Kruk <m@m10k.eu>
Wed, 13 Nov 2019 07:35:01 +0000 (16:35 +0900)
 - process_set_pagedir() / process_get_pagedir() - Convenience functions to access the process's pagedir
 - process_setuid() - Set the process's user id
 - process_setgid() - Set the process's group id

kernel/core/process.c
kernel/include/process.h

index 710fc7580d986c9c09f5b7b4e63b9b2e86b892b3..d1c860f98bce5ced6d8656249c9c1743d0d8e615 100644 (file)
@@ -857,3 +857,61 @@ int process_suspend(process_t *proc)
 
        return(ret_val);
 }
+
+int process_setuid(process_t *proc, uid_t uid)
+{
+       process_t *cproc;
+       int ret_val;
+
+       ret_val = -EINVAL;
+       cproc = process_get_current();
+
+       if(cproc) {
+               /* check if caller is allowed to do that */
+               ret_val = -EACCES;
+       }
+
+       return(ret_val);
+}
+
+int process_setgid(process_t *proc, gid_t gid)
+{
+       return(-ENOSYS);
+}
+
+int process_set_pagedir(process_t *proc, pg_dir_t *pd)
+{
+       int ret_val;
+
+       ret_val = -EINVAL;
+
+       if(proc && pd) {
+               /* FIXME: make sure none of the tasks are running */
+               proc->p_pgdir = pd;
+
+               /* FIXME: Set t_pgdir in all tasks */
+               proc->p_tasks->t_pgdir = (u32_t)pg_dir_get_pdbr(pd);
+
+               /*
+                * TODO: The old page directory may still be referenced
+                * by the tasks' return stacks. Should we handle that here?
+                */
+               ret_val = 0;
+       }
+
+       return(ret_val);
+}
+
+int process_get_pagedir(process_t *proc, pg_dir_t **pd)
+{
+       int ret_val;
+
+       ret_val = -EINVAL;
+
+       if(proc && pd) {
+               *pd = proc->p_pgdir;
+               ret_val = 0;
+       }
+
+       return(ret_val);
+}
index 03067e142e6cebb8e556fbaec3b5f937627bf19d..3e361fbf06c5ec2a7f4251a8ded38519772747a1 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <corax/types.h>
 #include <corax/ipc.h>
+#include <arch.h>
 
 #define PROC_ENTRY_FORK  ((void*)0)
 #define PROC_ENTRY_VFORK ((void*)1)
@@ -53,5 +54,10 @@ int           process_exit(process_t*, int);
 int           process_fork(int);
 int           process_detach(process_t*);
 int           process_suspend(process_t*);
+int           process_setuid(process_t*, uid_t);
+int           process_setgid(process_t*, gid_t);
+
+int           process_set_pagedir(process_t*, pg_dir_t*);
+int           process_get_pagedir(process_t*, pg_dir_t**);
 
 #endif /* __PROCESS_H */