sidsys.c revision f48205be61a214698b763ff550ab9e657525104c
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SID system call.
*/
static kmutex_t idmap_mutex;
typedef struct idmap_reg {
int idmap_flags;
int idmap_ref;
} idmap_reg_t;
static idmap_reg_t *idmap_ptr;
static int idmap_unreg_dh(door_handle_t);
static void
{
door_ki_rele(p->idmap_door);
if (idmap_ptr == p)
kmem_free(p, sizeof (*p));
}
static int
{
idmap_reg_t *p;
int ret;
int dres;
p = idmap_ptr;
if (p != NULL) {
p->idmap_ref++;
} else {
return (-1);
}
switch (dres) {
case EINTR:
case EAGAIN:
delay(1);
continue;
case EINVAL:
case EBADF:
(void) idmap_unreg_dh(p->idmap_door);
/* FALLTHROUGH */
default:
ret = -1;
goto out;
}
}
ret = 0;
out:
if (--p->idmap_ref == 0)
idmap_freeone(p);
return (ret);
}
/*
* Current code only attempts to map ids to sids.
*/
int
{
return (-1);
/* Larger SID return value; this usually happens */
return (0);
}
{
goto out;
/* Should never happen; the original buffer should be large enough */
goto out;
}
out:
return (res);
}
static int
{
int err;
}
idmp->idmap_flags = 0;
return (0);
}
static int
{
return (EINVAL);
}
if (idmap_ptr->idmap_flags != 0) {
return (EAGAIN);
}
return (0);
}
static int
idmap_unreg(int did)
{
int res;
if (res != 0)
return (0);
}
static boolean_t
its_my_door(void)
{
return (B_TRUE);
}
}
return (B_FALSE);
}
static uint64_t
{
rval_t r;
int err;
if (!its_my_door())
if (err != 0)
return (r.r_vals);
}
{
switch (op) {
case SIDSYS_ALLOC_IDS:
case SIDSYS_IDMAP_REG:
case SIDSYS_IDMAP_UNREG:
return (idmap_unreg(flag));
default:
}
}