Fork me on GitHub

root/kernel/syscalls/getrlimit.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_getrlimit

   1 /*
   2  * fiwix/kernel/syscalls/getrlimit.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/fs.h>
   9 #include <fiwix/resource.h>
  10 #include <fiwix/process.h>
  11 #include <fiwix/errno.h>
  12 
  13 #ifdef __DEBUG__
  14 #include <fiwix/stdio.h>
  15 #endif /*__DEBUG__ */
  16 
  17 int sys_getrlimit(int resource, struct rlimit *rlim)
  18 {
  19         int errno;
  20 
  21 #ifdef __DEBUG__
  22         printk("(pid %d) sys_getrlimit(%d, 0x%08x)\n", current->pid, resource, (unsigned int)rlim);
  23 #endif /*__DEBUG__ */
  24 
  25         if((errno = check_user_area(VERIFY_WRITE, rlim, sizeof(struct rlimit)))) {
  26                 return errno;
  27         }
  28         if(resource < 0 || resource >= RLIM_NLIMITS) {
  29                 return -EINVAL;
  30         }
  31 
  32         rlim->rlim_cur = current->rlim[resource].rlim_cur;
  33         rlim->rlim_max = current->rlim[resource].rlim_max;
  34         return 0;
  35 }

/* [previous][next][first][last][top][bottom][index][help] */