1*9acbbeafSnn /*
2*9acbbeafSnn  * CDDL HEADER START
3*9acbbeafSnn  *
4*9acbbeafSnn  * The contents of this file are subject to the terms of the
5*9acbbeafSnn  * Common Development and Distribution License (the "License").
6*9acbbeafSnn  * You may not use this file except in compliance with the License.
7*9acbbeafSnn  *
8*9acbbeafSnn  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9acbbeafSnn  * or http://www.opensolaris.org/os/licensing.
10*9acbbeafSnn  * See the License for the specific language governing permissions
11*9acbbeafSnn  * and limitations under the License.
12*9acbbeafSnn  *
13*9acbbeafSnn  * When distributing Covered Code, include this CDDL HEADER in each
14*9acbbeafSnn  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9acbbeafSnn  * If applicable, add the following below this CDDL HEADER, with the
16*9acbbeafSnn  * fields enclosed by brackets "[]" replaced with your own identifying
17*9acbbeafSnn  * information: Portions Copyright [yyyy] [name of copyright owner]
18*9acbbeafSnn  *
19*9acbbeafSnn  * CDDL HEADER END
20*9acbbeafSnn  */
21*9acbbeafSnn /*
22*9acbbeafSnn  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*9acbbeafSnn  * Use is subject to license terms.
24*9acbbeafSnn  */
25*9acbbeafSnn 
26*9acbbeafSnn #include <sys/brand.h>
27*9acbbeafSnn #include <sys/systm.h>
28*9acbbeafSnn #include <sys/types.h>
29*9acbbeafSnn #include <sys/zone.h>
30*9acbbeafSnn 
31*9acbbeafSnn /*
32*9acbbeafSnn  * brand(2) system call.
33*9acbbeafSnn  */
34*9acbbeafSnn int64_t
brandsys(int cmd,uintptr_t arg1,uintptr_t arg2,uintptr_t arg3,uintptr_t arg4,uintptr_t arg5,uintptr_t arg6)35*9acbbeafSnn brandsys(int cmd, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3,
36*9acbbeafSnn     uintptr_t arg4, uintptr_t arg5, uintptr_t arg6)
37*9acbbeafSnn {
38*9acbbeafSnn 	struct proc *p = curthread->t_procp;
39*9acbbeafSnn 	int64_t rval = 0;
40*9acbbeafSnn 	int err;
41*9acbbeafSnn 
42*9acbbeafSnn 	/*
43*9acbbeafSnn 	 * The brandsys system call can only be executed from inside a
44*9acbbeafSnn 	 * branded zone.
45*9acbbeafSnn 	 */
46*9acbbeafSnn 	if (INGLOBALZONE(p) || !ZONE_IS_BRANDED(p->p_zone))
47*9acbbeafSnn 		return (set_errno(ENOSYS));
48*9acbbeafSnn 
49*9acbbeafSnn 	if ((err = ZBROP(p->p_zone)->b_brandsys(cmd, &rval, arg1, arg2, arg3,
50*9acbbeafSnn 	    arg4, arg5, arg6)) != 0)
51*9acbbeafSnn 		return (set_errno(err));
52*9acbbeafSnn 
53*9acbbeafSnn 	return (rval);
54*9acbbeafSnn }
55