1 /* $NetBSD: osf1_resource.c,v 1.13 2008/04/24 18:39:23 ad Exp $ */
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: osf1_resource.c,v 1.13 2008/04/24 18:39:23 ad Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
39 #include <sys/mount.h>
40 #include <sys/syscallargs.h>
41 #include <sys/resource.h>
42 #include <sys/resourcevar.h>
44 #include <compat/osf1/osf1.h>
45 #include <compat/osf1/osf1_syscallargs.h>
46 #include <compat/osf1/osf1_cvt.h>
49 osf1_sys_getrlimit(struct lwp
*l
, const struct osf1_sys_getrlimit_args
*uap
, register_t
*retval
)
51 struct sys_getrlimit_args a
;
53 switch (SCARG(uap
, which
)) {
55 SCARG(&a
, which
) = RLIMIT_CPU
;
57 case OSF1_RLIMIT_FSIZE
:
58 SCARG(&a
, which
) = RLIMIT_FSIZE
;
60 case OSF1_RLIMIT_DATA
:
61 SCARG(&a
, which
) = RLIMIT_DATA
;
63 case OSF1_RLIMIT_STACK
:
64 SCARG(&a
, which
) = RLIMIT_STACK
;
66 case OSF1_RLIMIT_CORE
:
67 SCARG(&a
, which
) = RLIMIT_CORE
;
70 SCARG(&a
, which
) = RLIMIT_RSS
;
72 case OSF1_RLIMIT_NOFILE
:
73 SCARG(&a
, which
) = RLIMIT_NOFILE
;
76 SCARG(&a
, which
) = RLIMIT_AS
;
82 /* XXX should translate */
83 SCARG(&a
, rlp
) = SCARG(uap
, rlp
);
85 return sys_getrlimit(l
, &a
, retval
);
89 osf1_sys_getrusage(struct lwp
*l
, const struct osf1_sys_getrusage_args
*uap
, register_t
*retval
)
91 struct osf1_rusage osf1_rusage
;
93 struct proc
*p
= l
->l_proc
;
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
);
102 mutex_exit(p
->p_lock
);
105 case OSF1_RUSAGE_CHILDREN
:
106 ru
= p
->p_stats
->p_cru
;
109 case OSF1_RUSAGE_THREAD
: /* XXX not supported */
114 osf1_cvt_rusage_from_native(&ru
, &osf1_rusage
);
116 return copyout(&osf1_rusage
, SCARG(uap
, rusage
), sizeof osf1_rusage
);
120 osf1_sys_setrlimit(struct lwp
*l
, const struct osf1_sys_setrlimit_args
*uap
, register_t
*retval
)
122 struct sys_setrlimit_args a
;
124 switch (SCARG(uap
, which
)) {
125 case OSF1_RLIMIT_CPU
:
126 SCARG(&a
, which
) = RLIMIT_CPU
;
128 case OSF1_RLIMIT_FSIZE
:
129 SCARG(&a
, which
) = RLIMIT_FSIZE
;
131 case OSF1_RLIMIT_DATA
:
132 SCARG(&a
, which
) = RLIMIT_DATA
;
134 case OSF1_RLIMIT_STACK
:
135 SCARG(&a
, which
) = RLIMIT_STACK
;
137 case OSF1_RLIMIT_CORE
:
138 SCARG(&a
, which
) = RLIMIT_CORE
;
140 case OSF1_RLIMIT_RSS
:
141 SCARG(&a
, which
) = RLIMIT_RSS
;
143 case OSF1_RLIMIT_NOFILE
:
144 SCARG(&a
, which
) = RLIMIT_NOFILE
;
147 SCARG(&a
, which
) = RLIMIT_AS
;
153 /* XXX should translate */
154 SCARG(&a
, rlp
) = SCARG(uap
, rlp
);
156 return sys_setrlimit(l
, &a
, retval
);