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