8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libproc / common / pr_tasksys.c
blob7236e75dffeec0c68cf3f52632f38cae040577f5
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #define _LARGEFILE64_SOURCE
31 #include <sys/task.h>
32 #include <sys/types.h>
34 #include <zone.h>
35 #include <errno.h>
36 #include <project.h>
37 #include <stdlib.h>
38 #include <strings.h>
39 #include <unistd.h>
41 #include "libproc.h"
43 zoneid_t
44 pr_getzoneid(struct ps_prochandle *Pr)
46 sysret_t rval;
47 argdes_t argd[2];
48 argdes_t *adp;
49 int error;
51 if (Pr == NULL) /* no subject process */
52 return (getzoneid());
54 adp = &argd[0];
55 adp->arg_value = 6; /* switch for zone_lookup in zone */
56 adp->arg_object = NULL;
57 adp->arg_type = AT_BYVAL;
58 adp->arg_inout = AI_INPUT;
59 adp->arg_size = 0;
61 adp = &argd[1];
62 adp->arg_value = 0; /* arguement for zone_lookup in zone */
63 adp->arg_object = NULL;
64 adp->arg_type = AT_BYVAL;
65 adp->arg_inout = AI_INPUT;
66 adp->arg_size = 0;
68 error = Psyscall(Pr, &rval, SYS_zone, 2, &argd[0]);
70 if (error) {
71 errno = (error > 0) ? error : ENOSYS;
72 return (-1);
74 return (rval.sys_rval1);
77 projid_t
78 pr_getprojid(struct ps_prochandle *Pr)
80 sysret_t rval;
81 argdes_t argd[1];
82 argdes_t *adp;
83 int error;
85 if (Pr == NULL) /* no subject process */
86 return (getprojid());
88 adp = &argd[0];
89 adp->arg_value = 2; /* switch for getprojid in tasksys */
90 adp->arg_object = NULL;
91 adp->arg_type = AT_BYVAL;
92 adp->arg_inout = AI_INPUT;
93 adp->arg_size = 0;
95 error = Psyscall(Pr, &rval, SYS_tasksys, 1, &argd[0]);
97 if (error) {
98 errno = (error > 0) ? error : ENOSYS;
99 return (-1);
101 return (rval.sys_rval1);
104 taskid_t
105 pr_gettaskid(struct ps_prochandle *Pr)
107 sysret_t rval;
108 argdes_t argd[1];
109 argdes_t *adp;
110 int error;
112 if (Pr == NULL) /* no subject process */
113 return (gettaskid());
115 adp = &argd[0];
116 adp->arg_value = 1; /* switch for gettaskid in tasksys */
117 adp->arg_object = NULL;
118 adp->arg_type = AT_BYVAL;
119 adp->arg_inout = AI_INPUT;
120 adp->arg_size = 0;
122 error = Psyscall(Pr, &rval, SYS_tasksys, 1, &argd[0]);
124 if (error) {
125 errno = (error > 0) ? error : ENOSYS;
126 return (-1);
128 return (rval.sys_rval1);
131 taskid_t
132 pr_settaskid(struct ps_prochandle *Pr, projid_t project, int flags)
134 sysret_t rval;
135 argdes_t argd[3];
136 argdes_t *adp;
137 int error;
139 if (Pr == NULL) /* No subject process */
140 return (settaskid(project, flags));
142 adp = &argd[0];
143 adp->arg_value = 0; /* switch for settaskid in tasksys */
144 adp->arg_object = NULL;
145 adp->arg_type = AT_BYVAL;
146 adp->arg_inout = AI_INPUT;
147 adp->arg_size = 0;
149 adp++;
150 adp->arg_value = project;
151 adp->arg_object = NULL;
152 adp->arg_type = AT_BYVAL;
153 adp->arg_inout = AI_INPUT;
154 adp->arg_size = sizeof (project);
156 adp++;
157 adp->arg_value = flags;
158 adp->arg_object = NULL;
159 adp->arg_type = AT_BYVAL;
160 adp->arg_inout = AI_INPUT;
161 adp->arg_size = 0;
163 error = Psyscall(Pr, &rval, SYS_tasksys, 3, &argd[0]);
165 if (error) {
166 errno = (error > 0) ? error : ENOSYS;
167 return (-1);
169 return (rval.sys_rval1);