tasksys.c revision 0209230bf1261579beab4f55226bb509e6b850cb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* System calls for creating and inquiring about tasks and projects
*/
/*
* Limit projlist to 256k projects.
*/
#define MAX_PROJLIST_BUFSIZE 1048576
typedef struct projlist_walk {
/*
* taskid_t tasksys_settaskid(projid_t projid, uint_t flags);
*
* Overview
* Place the calling process in a new task if sufficiently privileged. If the
* present task is finalized, the process may not create a new task.
*
* Return values
* 0 on success, errno on failure.
*/
static long
{
int rctlfail = 0;
if (secpolicy_tasksys(CRED()) != 0)
if (flags & ~TASK_FINAL)
}
/*
* Try to stop all other lwps in the process while we're changing
* our project. This way, curthread doesn't need to grab its own
* thread_lock to find its project ID (see curprojid()). If this
* is the /proc agent lwp, we know that the other lwps are already
* held. If we failed to hold all lwps, bail out and return EINTR.
*/
/*
* Put a hold on our new project and make sure that nobody is
* trying to bind it to a pool while we're joining.
*/
e.rcep_t = RCENTITY_PROJECT;
mutex_enter(&p->p_lock);
rctlfail = 1;
1, 0) & RCT_DENY)
rctlfail = 1;
&e, p->p_locked_mem, 0) &RCT_DENY)
rctlfail = 1;
if (rctlfail) {
continuelwps(p);
mutex_exit(&p->p_lock);
}
kpj->kpj_ntasks++;
mutex_exit(&p->p_lock);
/*
* Returns with p_lock held.
*/
continuelwps(p);
mutex_exit(&p->p_lock);
}
/*
* taskid_t tasksys_gettaskid(void);
*
* Overview
* Return the current task ID for this process.
*
* Return value
* The ID for the task to which the current process belongs.
*/
static long
{
long ret;
return (ret);
}
/*
* projid_t tasksys_getprojid(void);
*
* Overview
* Return the current project ID for this process.
*
* Return value
* The ID for the project to which the current process belongs.
*/
static long
{
long ret;
return (ret);
}
static int
{
}
return (0);
}
/*
* long tasksys_projlist(void *buf, size_t bufsz)
*
* Overview
* Return a buffer containing the project IDs of all currently active projects
* in the current zone.
*
* Return values
* The minimum size of a buffer sufficiently large to contain all of the
* active project IDs, or -1 if an error occurs during copyout.
*/
static long
{
long ret = 0;
void *kbuf;
NULL));
if (bufsz > MAX_PROJLIST_BUFSIZE)
return (ret);
}
long
{
switch (code) {
case 0:
case 1:
return (tasksys_gettaskid());
case 2:
return (tasksys_getprojid());
case 3:
default:
}
}