xref: /illumos-gate/usr/src/lib/libc/port/sys/sidsys.c (revision 9fb67ea3)
1f48205beScasper /*
2f48205beScasper  * CDDL HEADER START
3f48205beScasper  *
4f48205beScasper  * The contents of this file are subject to the terms of the
5f48205beScasper  * Common Development and Distribution License (the "License").
6f48205beScasper  * You may not use this file except in compliance with the License.
7f48205beScasper  *
8f48205beScasper  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9f48205beScasper  * or http://www.opensolaris.org/os/licensing.
10f48205beScasper  * See the License for the specific language governing permissions
11f48205beScasper  * and limitations under the License.
12f48205beScasper  *
13f48205beScasper  * When distributing Covered Code, include this CDDL HEADER in each
14f48205beScasper  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15f48205beScasper  * If applicable, add the following below this CDDL HEADER, with the
16f48205beScasper  * fields enclosed by brackets "[]" replaced with your own identifying
17f48205beScasper  * information: Portions Copyright [yyyy] [name of copyright owner]
18f48205beScasper  *
19f48205beScasper  * CDDL HEADER END
20f48205beScasper  */
21f48205beScasper 
22f48205beScasper /*
23*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24f48205beScasper  * Use is subject to license terms.
25f48205beScasper  */
26f48205beScasper 
27f48205beScasper /*
28f48205beScasper  * UID/SID mapping system call entries.
29f48205beScasper  */
30f48205beScasper 
317257d1b4Sraf #include "lint.h"
32f48205beScasper #include <sys/sid.h>
33f48205beScasper #include <sys/syscall.h>
34f48205beScasper 
35f48205beScasper 
36f48205beScasper int
allocids(int flag,int nuids,uid_t * suid,int ngids,gid_t * sgid)37f48205beScasper allocids(int flag, int nuids, uid_t *suid, int ngids, gid_t *sgid)
38f48205beScasper {
39f48205beScasper 	sysret_t rv;
40f48205beScasper 	int e;
41f48205beScasper 
42f48205beScasper 	e = __systemcall(&rv, SYS_sidsys, SIDSYS_ALLOC_IDS, flag, nuids, ngids);
43f48205beScasper 
44f48205beScasper 	if (e != 0) {
45f48205beScasper 		(void) __set_errno(e);
46f48205beScasper 		return (-1);
47f48205beScasper 	}
48f48205beScasper 
49f48205beScasper 	if (suid != NULL)
50f48205beScasper 		*suid = (uid_t)rv.sys_rval1;
51f48205beScasper 	if (sgid != NULL)
52f48205beScasper 		*sgid = (gid_t)rv.sys_rval2;
53f48205beScasper 
54f48205beScasper 	return (0);
55f48205beScasper }
56f48205beScasper 
57f48205beScasper int
__idmap_reg(int fd)58*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States __idmap_reg(int fd)
59f48205beScasper {
60f48205beScasper 	return (syscall(SYS_sidsys, SIDSYS_IDMAP_REG, fd));
61f48205beScasper }
62f48205beScasper 
63f48205beScasper int
__idmap_unreg(int fd)64*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States __idmap_unreg(int fd)
65f48205beScasper {
66f48205beScasper 	return (syscall(SYS_sidsys, SIDSYS_IDMAP_UNREG, fd));
67f48205beScasper }
68*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 
69*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int
__idmap_flush_kcache(void)70*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States __idmap_flush_kcache(void)
71*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States {
72*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 	return (syscall(SYS_sidsys, SIDSYS_IDMAP_FLUSH_KCACHE));
73*9fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }
74