4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #define _LARGEFILE64_SOURCE
34 #include <sys/resource.h>
38 * getrlimit() system call -- executed by subject process.
41 pr_getrlimit(struct ps_prochandle
*Pr
,
42 int resource
, struct rlimit
*rlp
)
44 sysret_t rval
; /* return value from getrlimit() */
45 argdes_t argd
[2]; /* arg descriptors for getrlimit() */
50 if (Pr
== NULL
) /* no subject process */
51 return (getrlimit(resource
, rlp
));
53 adp
= &argd
[0]; /* resource argument */
54 adp
->arg_value
= resource
;
55 adp
->arg_object
= NULL
;
56 adp
->arg_type
= AT_BYVAL
;
57 adp
->arg_inout
= AI_INPUT
;
60 adp
++; /* rlp argument */
62 adp
->arg_object
= rlp
;
63 adp
->arg_type
= AT_BYREF
;
64 adp
->arg_inout
= AI_OUTPUT
;
65 adp
->arg_size
= sizeof (*rlp
);
68 if (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
)
69 sysnum
= SYS_getrlimit64
;
71 sysnum
= SYS_getrlimit
;
73 sysnum
= SYS_getrlimit
;
76 error
= Psyscall(Pr
, &rval
, sysnum
, 2, &argd
[0]);
79 errno
= (error
> 0)? error
: ENOSYS
;
82 return (rval
.sys_rval1
);
86 * setrlimit() system call -- executed by subject process.
89 pr_setrlimit(struct ps_prochandle
*Pr
,
90 int resource
, const struct rlimit
*rlp
)
92 sysret_t rval
; /* return value from setrlimit() */
93 argdes_t argd
[2]; /* arg descriptors for setrlimit() */
98 if (Pr
== NULL
) /* no subject process */
99 return (setrlimit(resource
, rlp
));
101 adp
= &argd
[0]; /* resource argument */
102 adp
->arg_value
= resource
;
103 adp
->arg_object
= NULL
;
104 adp
->arg_type
= AT_BYVAL
;
105 adp
->arg_inout
= AI_INPUT
;
108 adp
++; /* rlp argument */
110 adp
->arg_object
= (void *)rlp
;
111 adp
->arg_type
= AT_BYREF
;
112 adp
->arg_inout
= AI_INPUT
;
113 adp
->arg_size
= sizeof (*rlp
);
116 if (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
)
117 sysnum
= SYS_setrlimit64
;
119 sysnum
= SYS_setrlimit
;
121 sysnum
= SYS_setrlimit
;
124 error
= Psyscall(Pr
, &rval
, sysnum
, 2, &argd
[0]);
127 errno
= (error
> 0)? error
: ENOSYS
;
130 return (rval
.sys_rval1
);
134 * getrlimit64() system call -- executed by subject process.
137 pr_getrlimit64(struct ps_prochandle
*Pr
,
138 int resource
, struct rlimit64
*rlp
)
140 sysret_t rval
; /* return value from getrlimit() */
141 argdes_t argd
[2]; /* arg descriptors for getrlimit() */
146 if (Pr
== NULL
) /* no subject process */
147 return (getrlimit64(resource
, rlp
));
149 adp
= &argd
[0]; /* resource argument */
150 adp
->arg_value
= resource
;
151 adp
->arg_object
= NULL
;
152 adp
->arg_type
= AT_BYVAL
;
153 adp
->arg_inout
= AI_INPUT
;
156 adp
++; /* rlp argument */
158 adp
->arg_object
= rlp
;
159 adp
->arg_type
= AT_BYREF
;
160 adp
->arg_inout
= AI_OUTPUT
;
161 adp
->arg_size
= sizeof (*rlp
);
164 if (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
)
165 sysnum
= SYS_getrlimit64
;
167 sysnum
= SYS_getrlimit
;
169 sysnum
= SYS_getrlimit64
;
172 error
= Psyscall(Pr
, &rval
, sysnum
, 2, &argd
[0]);
175 errno
= (error
> 0)? error
: ENOSYS
;
178 return (rval
.sys_rval1
);
182 * setrlimit64() system call -- executed by subject process.
185 pr_setrlimit64(struct ps_prochandle
*Pr
,
186 int resource
, const struct rlimit64
*rlp
)
188 sysret_t rval
; /* return value from setrlimit() */
189 argdes_t argd
[2]; /* arg descriptors for setrlimit() */
194 if (Pr
== NULL
) /* no subject process */
195 return (setrlimit64(resource
, rlp
));
197 adp
= &argd
[0]; /* resource argument */
198 adp
->arg_value
= resource
;
199 adp
->arg_object
= NULL
;
200 adp
->arg_type
= AT_BYVAL
;
201 adp
->arg_inout
= AI_INPUT
;
204 adp
++; /* rlp argument */
206 adp
->arg_object
= (void *)rlp
;
207 adp
->arg_type
= AT_BYREF
;
208 adp
->arg_inout
= AI_INPUT
;
209 adp
->arg_size
= sizeof (*rlp
);
212 if (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
)
213 sysnum
= SYS_setrlimit64
;
215 sysnum
= SYS_setrlimit
;
217 sysnum
= SYS_setrlimit64
;
220 error
= Psyscall(Pr
, &rval
, sysnum
, 2, &argd
[0]);
223 errno
= (error
> 0)? error
: ENOSYS
;
226 return (rval
.sys_rval1
);