The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_resource.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: osf1_resource.c,v 1.13.12.1 2009/04/01 00:25:22 snj Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __KERNEL_RCSID(0, "$NetBSD: osf1_resource.c,v 1.13.12.1 2009/04/01 00:25:22 snj Exp $");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/proc.h>
   39 #include <sys/mount.h>
   40 #include <sys/syscallargs.h>
   41 #include <sys/resource.h>
   42 #include <sys/resourcevar.h>
   43 
   44 #include <compat/osf1/osf1.h>
   45 #include <compat/osf1/osf1_syscallargs.h>
   46 #include <compat/osf1/osf1_cvt.h>
   47 
   48 int
   49 osf1_sys_getrlimit(struct lwp *l, const struct osf1_sys_getrlimit_args *uap, register_t *retval)
   50 {
   51         struct sys_getrlimit_args a;
   52 
   53         switch (SCARG(uap, which)) {
   54         case OSF1_RLIMIT_CPU:
   55                 SCARG(&a, which) = RLIMIT_CPU;
   56                 break;
   57         case OSF1_RLIMIT_FSIZE:
   58                 SCARG(&a, which) = RLIMIT_FSIZE;
   59                 break;
   60         case OSF1_RLIMIT_DATA:
   61                 SCARG(&a, which) = RLIMIT_DATA;
   62                 break;
   63         case OSF1_RLIMIT_STACK:
   64                 SCARG(&a, which) = RLIMIT_STACK;
   65                 break;
   66         case OSF1_RLIMIT_CORE:
   67                 SCARG(&a, which) = RLIMIT_CORE;
   68                 break;
   69         case OSF1_RLIMIT_RSS:
   70                 SCARG(&a, which) = RLIMIT_RSS;
   71                 break;
   72         case OSF1_RLIMIT_NOFILE:
   73                 SCARG(&a, which) = RLIMIT_NOFILE;
   74                 break;
   75         case OSF1_RLIMIT_AS:
   76                 SCARG(&a, which) = RLIMIT_AS;
   77                 break;
   78         default:
   79                 return (EINVAL);
   80         }
   81 
   82         /* XXX should translate */
   83         SCARG(&a, rlp) = SCARG(uap, rlp);
   84 
   85         return sys_getrlimit(l, &a, retval);
   86 }
   87 
   88 int
   89 osf1_sys_getrusage(struct lwp *l, const struct osf1_sys_getrusage_args *uap, register_t *retval)
   90 {
   91         struct osf1_rusage osf1_rusage;
   92         struct rusage ru;
   93         struct proc *p = l->l_proc;
   94 
   95 
   96         switch (SCARG(uap, who)) {
   97         case OSF1_RUSAGE_SELF:
   98                 mutex_enter(p->p_lock);
   99                 ru = p->p_stats->p_ru;
  100                 calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL);
  101                 rulwps(p, &ru);
  102                 mutex_exit(p->p_lock);
  103                 break;
  104 
  105         case OSF1_RUSAGE_CHILDREN:
  106                 ru = p->p_stats->p_cru;
  107                 break;
  108 
  109         case OSF1_RUSAGE_THREAD:                /* XXX not supported */
  110         default:
  111                 return (EINVAL);
  112         }
  113 
  114         osf1_cvt_rusage_from_native(&ru, &osf1_rusage);
  115 
  116         return copyout(&osf1_rusage, SCARG(uap, rusage), sizeof osf1_rusage);
  117 }
  118 
  119 int
  120 osf1_sys_setrlimit(struct lwp *l, const struct osf1_sys_setrlimit_args *uap, register_t *retval)
  121 {
  122         struct sys_setrlimit_args a;
  123 
  124         switch (SCARG(uap, which)) {
  125         case OSF1_RLIMIT_CPU:
  126                 SCARG(&a, which) = RLIMIT_CPU;
  127                 break;
  128         case OSF1_RLIMIT_FSIZE:
  129                 SCARG(&a, which) = RLIMIT_FSIZE;
  130                 break;
  131         case OSF1_RLIMIT_DATA:
  132                 SCARG(&a, which) = RLIMIT_DATA;
  133                 break;
  134         case OSF1_RLIMIT_STACK:
  135                 SCARG(&a, which) = RLIMIT_STACK;
  136                 break;
  137         case OSF1_RLIMIT_CORE:
  138                 SCARG(&a, which) = RLIMIT_CORE;
  139                 break;
  140         case OSF1_RLIMIT_RSS:
  141                 SCARG(&a, which) = RLIMIT_RSS;
  142                 break;
  143         case OSF1_RLIMIT_NOFILE:
  144                 SCARG(&a, which) = RLIMIT_NOFILE;
  145                 break;
  146         case OSF1_RLIMIT_AS:
  147                 SCARG(&a, which) = RLIMIT_AS;
  148                 break;
  149         default:
  150                 return (EINVAL);
  151         }
  152 
  153         /* XXX should translate */
  154         SCARG(&a, rlp) = SCARG(uap, rlp);
  155 
  156         return sys_setrlimit(l, &a, retval);
  157 }

Cache object: 75a522a97e9f3500ea33c9bbfc70d09e


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.