]> git.corax.cc Git - corax/commitdiff
Add process_flookup() and process_get_current() functions
authorMatthias Kruk <m@m10k.eu>
Fri, 4 Oct 2019 06:37:58 +0000 (15:37 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 4 Oct 2019 06:37:58 +0000 (15:37 +0900)
kernel/core/process.c
kernel/include/process.h

index 06b00c81536ab43960f75b29018fd5c5ececb8c8..f57276ea7f89dfe09737763bca5dad8085647f0e 100644 (file)
@@ -135,3 +135,35 @@ int process_ffree(process_t *proc, int fd)
 
        return(ret_val);
 }
+
+int process_flookup(process_t *proc, int procfd)
+{
+       int ret_val;
+
+       ret_val = -EINVAL;
+
+       if(procfd >= 0 && procfd < (sizeof(proc->p_fds) / sizeof(proc->p_fds[0]))) {
+               ret_val = -EBADF;
+
+               if(proc->p_fds[procfd].fd_flags & FD_VALID) {
+                       ret_val = proc->p_fds[procfd].fd_socknum;
+               }
+       }
+
+       return(ret_val);
+}
+
+process_t* process_get_current(void)
+{
+       process_t *ret_val;
+       task_t *ctask;
+
+       ret_val = NULL;
+       ctask = task_get_current();
+
+       if(ctask) {
+               ret_val = (process_t*)ctask->t_proc;
+       }
+
+       return(ret_val);
+}
index 3b1e566a776b7fb38dd422116561be147dcbf2e3..9c398f7f450fae8eb3ec2cca98cad56dcd772efb 100644 (file)
@@ -28,5 +28,8 @@ int process_switch(process_t*);
 
 int process_falloc(process_t*, int);
 int process_ffree(process_t*, int);
+int process_flookup(process_t*, int);
+
+process_t* process_get_current(void);
 
 #endif /* __PROCESS_H */