4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #define _LARGEFILE64_SOURCE
35 #include <sys/rctl_impl.h>
38 * getrctl() system call -- executed by subject process
41 pr_getrctl(struct ps_prochandle
*Pr
, const char *rname
,
42 rctlblk_t
*old_blk
, rctlblk_t
*new_blk
, int rflag
)
49 if (Pr
== NULL
) /* no subject process */
50 return (getrctl(rname
, old_blk
, new_blk
, rflag
));
53 adp
->arg_value
= 0; /* switch for getrctl in rctlsys */
54 adp
->arg_object
= NULL
;
55 adp
->arg_type
= AT_BYVAL
;
56 adp
->arg_inout
= AI_INPUT
;
61 adp
->arg_object
= (void *)rname
;
62 adp
->arg_type
= AT_BYREF
;
63 adp
->arg_inout
= AI_INPUT
;
64 adp
->arg_size
= strlen(rname
) + 1;
67 if (old_blk
== NULL
) {
69 adp
->arg_object
= NULL
;
70 adp
->arg_type
= AT_BYVAL
;
71 adp
->arg_inout
= AI_INPUT
;
75 adp
->arg_object
= old_blk
;
76 adp
->arg_type
= AT_BYREF
;
77 adp
->arg_inout
= AI_INPUT
;
78 adp
->arg_size
= rctlblk_size();
82 if (new_blk
== NULL
) {
84 adp
->arg_object
= NULL
;
85 adp
->arg_type
= AT_BYVAL
;
86 adp
->arg_inout
= AI_OUTPUT
;
90 adp
->arg_object
= new_blk
;
91 adp
->arg_type
= AT_BYREF
;
92 adp
->arg_inout
= AI_INOUT
;
93 adp
->arg_size
= rctlblk_size();
97 adp
->arg_value
= 0; /* obufsz isn't used by getrctl() */
98 adp
->arg_object
= NULL
;
99 adp
->arg_type
= AT_BYVAL
;
100 adp
->arg_inout
= AI_INPUT
;
104 adp
->arg_value
= rflag
;
105 adp
->arg_object
= NULL
;
106 adp
->arg_type
= AT_BYVAL
;
107 adp
->arg_inout
= AI_INPUT
;
110 error
= Psyscall(Pr
, &rval
, SYS_rctlsys
, 6, &argd
[0]);
113 errno
= (error
> 0) ? error
: ENOSYS
;
116 return (rval
.sys_rval1
);
120 * setrctl() system call -- executed by subject process
123 pr_setrctl(struct ps_prochandle
*Pr
, const char *rname
,
124 rctlblk_t
*old_blk
, rctlblk_t
*new_blk
, int rflag
)
131 if (Pr
== NULL
) /* no subject process */
132 return (setrctl(rname
, old_blk
, new_blk
, rflag
));
135 adp
->arg_value
= 1; /* switch for setrctl in rctlsys */
136 adp
->arg_object
= NULL
;
137 adp
->arg_type
= AT_BYVAL
;
138 adp
->arg_inout
= AI_INPUT
;
143 adp
->arg_object
= (void *)rname
;
144 adp
->arg_type
= AT_BYREF
;
145 adp
->arg_inout
= AI_INPUT
;
146 adp
->arg_size
= strlen(rname
) + 1;
149 if (old_blk
== NULL
) {
151 adp
->arg_object
= NULL
;
152 adp
->arg_type
= AT_BYVAL
;
153 adp
->arg_inout
= AI_INPUT
;
157 adp
->arg_object
= old_blk
;
158 adp
->arg_type
= AT_BYREF
;
159 adp
->arg_inout
= AI_INPUT
;
160 adp
->arg_size
= rctlblk_size();
164 if (new_blk
== NULL
) {
166 adp
->arg_object
= NULL
;
167 adp
->arg_type
= AT_BYVAL
;
168 adp
->arg_inout
= AI_INPUT
;
172 adp
->arg_object
= new_blk
;
173 adp
->arg_type
= AT_BYREF
;
174 adp
->arg_inout
= AI_INPUT
;
175 adp
->arg_size
= rctlblk_size();
179 adp
->arg_value
= 0; /* obufsz isn't used by setrctl() */
180 adp
->arg_object
= NULL
;
181 adp
->arg_type
= AT_BYVAL
;
182 adp
->arg_inout
= AI_INPUT
;
186 adp
->arg_value
= rflag
;
187 adp
->arg_object
= NULL
;
188 adp
->arg_type
= AT_BYVAL
;
189 adp
->arg_inout
= AI_INPUT
;
192 error
= Psyscall(Pr
, &rval
, SYS_rctlsys
, 6, &argd
[0]);
195 errno
= (error
> 0) ? error
: ENOSYS
;
198 return (rval
.sys_rval1
);
202 * setprojrctl() system call -- executed by subject process
205 pr_setprojrctl(struct ps_prochandle
*Pr
, const char *rname
,
206 rctlblk_t
*new_blk
, size_t size
, int rflag
)
213 if (Pr
== NULL
) /* no subject process */
214 return (setprojrctl(rname
, new_blk
, size
, rflag
));
217 adp
->arg_value
= 4; /* switch for setprojrctls in rctlsys */
218 adp
->arg_object
= NULL
;
219 adp
->arg_type
= AT_BYVAL
;
220 adp
->arg_inout
= AI_INPUT
;
225 adp
->arg_object
= (void *)rname
;
226 adp
->arg_type
= AT_BYREF
;
227 adp
->arg_inout
= AI_INPUT
;
228 adp
->arg_size
= strlen(rname
) + 1;
231 adp
->arg_value
= 0; /* old_blk is not used by setprojrctls() */
232 adp
->arg_object
= NULL
;
233 adp
->arg_type
= AT_BYVAL
;
234 adp
->arg_inout
= AI_INPUT
;
239 if (new_blk
== NULL
) {
241 adp
->arg_object
= NULL
;
242 adp
->arg_type
= AT_BYVAL
;
243 adp
->arg_inout
= AI_INPUT
;
247 adp
->arg_object
= new_blk
;
248 adp
->arg_type
= AT_BYREF
;
249 adp
->arg_inout
= AI_INPUT
;
250 adp
->arg_size
= rctlblk_size() * size
;
254 adp
->arg_value
= size
; /* obufsz is used by setrctls() */
255 adp
->arg_object
= NULL
;
256 adp
->arg_type
= AT_BYVAL
;
257 adp
->arg_inout
= AI_INPUT
;
261 adp
->arg_value
= rflag
;
262 adp
->arg_object
= NULL
;
263 adp
->arg_type
= AT_BYVAL
;
264 adp
->arg_inout
= AI_INPUT
;
267 error
= Psyscall(Pr
, &rval
, SYS_rctlsys
, 6, &argd
[0]);
270 errno
= (error
> 0) ? error
: ENOSYS
;
273 return (rval
.sys_rval1
);