xref: /illumos-gate/usr/src/lib/libfakekernel/common/sys/zone.h (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24  */
25 
26 #ifndef _SYS_ZONE_H
27 #define	_SYS_ZONE_H
28 
29 #include <sys/types.h>
30 #include <sys/mutex.h>
31 #include <sys/param.h>
32 #include <sys/cred.h>
33 #include <sys/rctl.h>
34 #include <sys/ksynch.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * NOTE
42  *
43  * The contents of this file are private to the implementation of
44  * Solaris and are subject to change at any time without notice.
45  * Applications and drivers using these interfaces may fail to
46  * run on future releases.
47  */
48 
49 #define	GLOBAL_ZONEID	0
50 #define	ZONENAME_MAX	64
51 
52 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
53 
54 #include <sys/list.h>
55 
56 typedef struct zone_ref {
57 	struct zone	*zref_zone; /* the zone to which the reference refers */
58 	list_node_t	zref_linkage; /* linkage for zone_t::zone_ref_list */
59 } zone_ref_t;
60 
61 typedef struct zone {
62 	char		*zone_name;	/* zone's configuration name */
63 	zoneid_t	zone_id;	/* ID of zone */
64 	struct proc	*zone_zsched;	/* Dummy kernel "zsched" process */
65 	time_t		zone_boot_time;
66 	struct vnode	*zone_rootvp;	/* zone's root vnode */
67 	char		*zone_rootpath;	/* Path to zone's root + '/' */
68 	int fake_zone[10];
69 } zone_t;
70 
71 extern zone_t zone0;
72 extern zone_t *global_zone;
73 extern uint_t maxzones;
74 
75 /*
76  * Zone-specific data (ZSD) APIs
77  */
78 /*
79  * The following is what code should be initializing its zone_key_t to if it
80  * calls zone_getspecific() without necessarily knowing that zone_key_create()
81  * has been called on the key.
82  */
83 #define	ZONE_KEY_UNINITIALIZED	0
84 
85 typedef uint_t zone_key_t;
86 
87 extern void	zone_key_create(zone_key_t *, void *(*)(zoneid_t),
88     void (*)(zoneid_t, void *), void (*)(zoneid_t, void *));
89 extern int 	zone_key_delete(zone_key_t);
90 extern void	*zone_getspecific(zone_key_t, zone_t *);
91 extern int	zone_setspecific(zone_key_t, zone_t *, const void *);
92 
93 extern zoneid_t getzoneid(void);
94 
95 #endif	/* _KERNEL || _FAKE_KERNEL */
96 
97 #ifdef	__cplusplus
98 }
99 #endif
100 
101 #endif	/* _SYS_ZONE_H */
102