xref: /titanic_52/usr/src/lib/libinstzones/hdrs/instzones_api.h (revision 9e421ec8af8c1a649841be72a22ee355f2e5e9c5)
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 /*
23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _INSTZONES_API_H
27 #define	_INSTZONES_API_H
28 
29 
30 /*
31  * Module:	instzones_api.h
32  * Group:	libinstzones
33  * Description:	This module contains the libinstzones API data structures,
34  *		constants, and function prototypes.
35  */
36 
37 /*
38  * required includes
39  */
40 
41 /* System includes */
42 
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <string.h>
46 #include <termios.h>
47 #include <sys/mman.h>
48 #include <sys/param.h>
49 #include <sys/types.h>
50 #include <sys/ioctl.h>
51 #include <libzonecfg.h>
52 
53 /*
54  * C++ prefix
55  */
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 /* function prototypes */
63 
64 /* PRINTFLIKE1 */
65 typedef void (*_z_printf_fcn_t)(char *a_format, ...);
66 
67 /* zone list structure */
68 
69 typedef struct _zoneListElement_t *zoneList_t;
70 
71 /* zone brand list structure */
72 
73 typedef struct _zoneBrandList zoneBrandList_t;
74 
75 /* flag for zone locking functions */
76 
77 typedef unsigned long ZLOCKS_T;
78 
79 /* flags for zone locking */
80 
81 #define	ZLOCKS_ZONE_ADMIN	((ZLOCKS_T)0x00000001)	/* zone admin */
82 #define	ZLOCKS_PKG_ADMIN	((ZLOCKS_T)0x00000002)	/* package admin */
83 #define	ZLOCKS_PATCH_ADMIN	((ZLOCKS_T)0x00000004)	/* patch admin */
84 #define	ZLOCKS_ALL		((ZLOCKS_T)0xFFFFFFFF)	/* all locks */
85 #define	ZLOCKS_NONE		((ZLOCKS_T)0x00000000)	/* no locks */
86 
87 /*
88  * external function definitions
89  */
90 
91 /* zones.c */
92 
93 extern boolean_t	z_zones_are_implemented(void);
94 extern void		z_set_zone_root(const char *zroot);
95 extern boolean_t	z_zlist_is_zone_runnable(zoneList_t a_zoneList,
96 				int a_zoneIndex);
97 extern boolean_t	z_zlist_restore_zone_state(zoneList_t a_zoneList,
98 				int a_zoneIndex);
99 extern boolean_t	z_zlist_change_zone_state(zoneList_t a_zoneList,
100 				int a_zoneIndex, zone_state_t a_newState);
101 extern char		*z_get_zonename(void);
102 extern zone_state_t	z_zlist_get_current_state(zoneList_t a_zoneList,
103 				int a_zoneIndex);
104 extern zone_state_t	z_zlist_get_original_state(zoneList_t a_zoneList,
105 				int a_zoneIndex);
106 extern int		z_zoneExecCmdArray(int *r_status, char **r_results,
107 				char *a_inputFile, char *a_path, char *a_argv[],
108 				const char *a_zoneName, int *a_fds);
109 extern int		z_zone_exec(const char *zonename, const char *path,
110 				char *argv[], char *a_stdoutPath,
111 				char *a_stderrPath, int *a_fds);
112 extern boolean_t	z_create_zone_admin_file(char *a_zoneAdminFilename,
113 				char *a_userAdminFilename);
114 extern void		z_free_zone_list(zoneList_t a_zoneList);
115 extern zoneList_t	z_get_nonglobal_zone_list(void);
116 extern zoneList_t	z_get_nonglobal_zone_list_by_brand(zoneBrandList_t *);
117 extern void		z_free_brand_list(zoneBrandList_t *a_brandList);
118 extern zoneBrandList_t	*z_make_brand_list(const char *brandList,
119 				const char *delim);
120 extern boolean_t	z_lock_zones(zoneList_t a_zlst, ZLOCKS_T a_lflags);
121 extern boolean_t	z_non_global_zones_exist(void);
122 extern boolean_t	z_running_in_global_zone(void);
123 extern void		z_set_output_functions(_z_printf_fcn_t a_echo_fcn,
124 				_z_printf_fcn_t a_echo_debug_fcn,
125 				_z_printf_fcn_t a_progerr_fcn);
126 extern int		z_set_zone_spec(const char *zlist);
127 extern int		z_verify_zone_spec(void);
128 extern boolean_t	z_on_zone_spec(const char *zonename);
129 extern boolean_t	z_global_only(void);
130 extern boolean_t	z_unlock_zones(zoneList_t a_zlst, ZLOCKS_T a_lflags);
131 extern boolean_t	z_lock_this_zone(ZLOCKS_T a_lflags);
132 extern boolean_t	z_unlock_this_zone(ZLOCKS_T a_lflags);
133 extern char		*z_zlist_get_zonename(zoneList_t a_zoneList,
134 				int a_zoneId);
135 extern char		*z_zlist_get_zonepath(zoneList_t a_zoneList,
136 				int a_zoneId);
137 extern char		*z_zlist_get_scratch(zoneList_t a_zoneList,
138 				int a_zoneId);
139 extern boolean_t	z_umount_lz_mount(char *a_lzMountPoint);
140 extern boolean_t	z_mount_in_lz(char **r_lzMountPoint,
141 				char **r_lzRootPath,
142 				char *a_zoneName, char *a_gzPath,
143 				char *a_mountPointPrefix);
144 extern boolean_t	z_is_zone_branded(char *zoneName);
145 extern boolean_t	z_is_zone_brand_in_list(char *zoneName,
146 			    zoneBrandList_t *brands);
147 extern boolean_t	z_zones_are_implemented(void);
148 
149 /* zones_exec.c */
150 extern int		z_ExecCmdArray(int *r_status, char **r_results,
151 				char *a_inputFile, char *a_cmd, char **a_args);
152 /*VARARGS*/
153 extern int		z_ExecCmdList(int *r_status, char **r_results,
154 				char *a_inputFile, char *a_cmd, ...);
155 
156 /* zones_paths.c */
157 extern char		*z_make_zone_root(char *);
158 extern void		z_path_canonize(char *file);
159 extern void		z_canoninplace(char *file);
160 
161 /* zones_lofs.c */
162 extern void z_destroyMountTable(void);
163 extern int z_createMountTable(void);
164 extern int z_isPathWritable(const char *);
165 extern void z_resolve_lofs(char *path, size_t);
166 
167 /* zones_states.c */
168 extern int UmountAllZones(char *mntpnt);
169 
170 /*
171  * C++ postfix
172  */
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif /* _INSTZONES_API_H */
179