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 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _LIBZONECFG_H 28 #define _LIBZONECFG_H 29 30 /* 31 * Zone configuration header file. 32 */ 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* sys/socket.h is required by net/if.h, which has a constant needed here */ 39 #include <sys/param.h> 40 #include <sys/fstyp.h> 41 #include <sys/mount.h> 42 #include <priv.h> 43 #include <netinet/in.h> 44 #include <sys/socket.h> 45 #include <net/if.h> 46 #include <stdio.h> 47 #include <rctl.h> 48 #include <zone.h> 49 #include <libbrand.h> 50 #include <sys/uuid.h> 51 #include <libuutil.h> 52 53 #define ZONE_ID_UNDEFINED -1 54 55 #define Z_OK 0 56 #define Z_EMPTY_DOCUMENT 1 /* XML doc root element is null */ 57 #define Z_WRONG_DOC_TYPE 2 /* top-level XML doc element != zone */ 58 #define Z_BAD_PROPERTY 3 /* libxml-level property problem */ 59 #define Z_TEMP_FILE 4 /* problem creating temporary file */ 60 #define Z_SAVING_FILE 5 /* libxml error saving or validating */ 61 #define Z_NO_ENTRY 6 /* no such entry */ 62 #define Z_BOGUS_ZONE_NAME 7 /* illegal zone name */ 63 #define Z_REQD_RESOURCE_MISSING 8 /* required resource missing */ 64 #define Z_REQD_PROPERTY_MISSING 9 /* required property missing */ 65 #define Z_BAD_HANDLE 10 /* bad document handle */ 66 #define Z_NOMEM 11 /* out of memory (like ENOMEM) */ 67 #define Z_INVAL 12 /* invalid argument (like EINVAL) */ 68 #define Z_ACCES 13 /* permission denied (like EACCES) */ 69 #define Z_TOO_BIG 14 /* string won't fit in char array */ 70 #define Z_MISC_FS 15 /* miscellaneous file-system error */ 71 #define Z_NO_ZONE 16 /* no such zone */ 72 #define Z_NO_RESOURCE_TYPE 17 /* no/wrong resource type */ 73 #define Z_NO_RESOURCE_ID 18 /* no/wrong resource id */ 74 #define Z_NO_PROPERTY_TYPE 19 /* no/wrong property type */ 75 #define Z_NO_PROPERTY_ID 20 /* no/wrong property id */ 76 #define Z_BAD_ZONE_STATE 21 /* zone state invalid for given task */ 77 #define Z_INVALID_DOCUMENT 22 /* libxml can't validate against DTD */ 78 #define Z_NAME_IN_USE 23 /* zone name already in use (rename) */ 79 #define Z_NO_SUCH_ID 24 /* delete_index: no old ID */ 80 #define Z_UPDATING_INDEX 25 /* add/modify/delete_index problem */ 81 #define Z_LOCKING_FILE 26 /* problem locking index file */ 82 #define Z_UNLOCKING_FILE 27 /* problem unlocking index file */ 83 #define Z_SYSTEM 28 /* consult errno instead */ 84 #define Z_INSUFFICIENT_SPEC 29 /* resource insufficiently specified */ 85 #define Z_RESOLVED_PATH 34 /* resolved path mismatch */ 86 #define Z_IPV6_ADDR_PREFIX_LEN 35 /* IPv6 address prefix length needed */ 87 #define Z_BOGUS_ADDRESS 36 /* not IPv[4|6] address or host name */ 88 #define Z_PRIV_PROHIBITED 37 /* specified privilege is prohibited */ 89 #define Z_PRIV_REQUIRED 38 /* required privilege is missing */ 90 #define Z_PRIV_UNKNOWN 39 /* specified privilege is unknown */ 91 #define Z_BRAND_ERROR 40 /* brand-specific error */ 92 #define Z_INCOMPATIBLE 41 /* incompatible settings */ 93 #define Z_ALIAS_DISALLOW 42 /* rctl alias disallowed */ 94 #define Z_CLEAR_DISALLOW 43 /* clear property disallowed */ 95 #define Z_POOL 44 /* generic libpool error */ 96 #define Z_POOLS_NOT_ACTIVE 45 /* pool service not enabled */ 97 #define Z_POOL_ENABLE 46 /* pools enable failed */ 98 #define Z_NO_POOL 47 /* no such pool configured */ 99 #define Z_POOL_CREATE 48 /* pool create failed */ 100 #define Z_POOL_BIND 49 /* pool bind failed */ 101 #define Z_HOSTID_FUBAR 50 /* invalid hostid provided */ 102 103 /* 104 * Warning: these are shared with the admin/install consolidation. 105 * Do not insert states between any of the currently defined states, 106 * and any new states must be evaluated for impact on range comparisons. 107 */ 108 #define ZONE_STATE_CONFIGURED 0 109 #define ZONE_STATE_INCOMPLETE 1 110 #define ZONE_STATE_INSTALLED 2 111 #define ZONE_STATE_READY 3 112 #define ZONE_STATE_RUNNING 4 113 #define ZONE_STATE_SHUTTING_DOWN 5 114 #define ZONE_STATE_DOWN 6 115 #define ZONE_STATE_MOUNTED 7 116 117 #define ZONE_STATE_MAXSTRLEN 14 118 119 #define LIBZONECFG_PATH "libzonecfg.so.1" 120 121 #define ZONE_CONFIG_ROOT "/etc/zones" 122 #define ZONE_INDEX_FILE ZONE_CONFIG_ROOT "/index" 123 124 /* Owner, group, and mode (defined by packaging) for the config directory */ 125 #define ZONE_CONFIG_UID 0 /* root */ 126 #define ZONE_CONFIG_GID 3 /* sys */ 127 #define ZONE_CONFIG_MODE 0755 128 129 /* Owner, group, and mode (defined by packaging) for the index file */ 130 #define ZONE_INDEX_UID 0 /* root */ 131 #define ZONE_INDEX_GID 3 /* sys */ 132 #define ZONE_INDEX_MODE 0644 133 134 /* The maximum length of the VERSION string in the pkginfo(4) file. */ 135 #define ZONE_PKG_VERSMAX 256 136 137 /* 138 * Shortened alias names for the zones rctls. 139 */ 140 #define ALIAS_MAXLWPS "max-lwps" 141 #define ALIAS_MAXSHMMEM "max-shm-memory" 142 #define ALIAS_MAXSHMIDS "max-shm-ids" 143 #define ALIAS_MAXMSGIDS "max-msg-ids" 144 #define ALIAS_MAXSEMIDS "max-sem-ids" 145 #define ALIAS_MAXLOCKEDMEM "locked" 146 #define ALIAS_MAXSWAP "swap" 147 #define ALIAS_SHARES "cpu-shares" 148 #define ALIAS_CPUCAP "cpu-cap" 149 150 /* Default name for zone detached manifest */ 151 #define ZONE_DETACHED "SUNWdetached.xml" 152 153 /* 154 * Bit flag definitions for passing into libzonecfg functions. 155 */ 156 #define ZONE_DRY_RUN 0x01 157 158 /* 159 * The integer field expresses the current values on a get. 160 * On a put, it represents the new values if >= 0 or "don't change" if < 0. 161 */ 162 struct zoneent { 163 char zone_name[ZONENAME_MAX]; /* name of the zone */ 164 int zone_state; /* configured | incomplete | installed */ 165 char zone_path[MAXPATHLEN]; /* path to zone storage */ 166 uuid_t zone_uuid; /* unique ID for zone */ 167 char zone_newname[ZONENAME_MAX]; /* for doing renames */ 168 }; 169 170 typedef struct zone_dochandle *zone_dochandle_t; /* opaque handle */ 171 172 typedef uint_t zone_state_t; 173 174 typedef struct zone_fsopt { 175 struct zone_fsopt *zone_fsopt_next; 176 char zone_fsopt_opt[MAX_MNTOPT_STR]; 177 } zone_fsopt_t; 178 179 struct zone_fstab { 180 char zone_fs_special[MAXPATHLEN]; /* special file */ 181 char zone_fs_dir[MAXPATHLEN]; /* mount point */ 182 char zone_fs_type[FSTYPSZ]; /* e.g. ufs */ 183 zone_fsopt_t *zone_fs_options; /* mount options */ 184 char zone_fs_raw[MAXPATHLEN]; /* device to fsck */ 185 }; 186 187 struct zone_nwiftab { 188 char zone_nwif_address[INET6_ADDRSTRLEN]; 189 char zone_nwif_physical[LIFNAMSIZ]; 190 char zone_nwif_defrouter[INET6_ADDRSTRLEN]; 191 }; 192 193 struct zone_devtab { 194 char zone_dev_match[MAXPATHLEN]; 195 }; 196 197 struct zone_rctlvaltab { 198 char zone_rctlval_priv[MAXNAMELEN]; 199 char zone_rctlval_limit[MAXNAMELEN]; 200 char zone_rctlval_action[MAXNAMELEN]; 201 struct zone_rctlvaltab *zone_rctlval_next; 202 }; 203 204 struct zone_rctltab { 205 char zone_rctl_name[MAXNAMELEN]; 206 struct zone_rctlvaltab *zone_rctl_valptr; 207 }; 208 209 struct zone_attrtab { 210 char zone_attr_name[MAXNAMELEN]; 211 char zone_attr_type[MAXNAMELEN]; 212 char zone_attr_value[2 * BUFSIZ]; 213 }; 214 215 struct zone_dstab { 216 char zone_dataset_name[MAXNAMELEN]; 217 }; 218 219 struct zone_psettab { 220 char zone_ncpu_min[MAXNAMELEN]; 221 char zone_ncpu_max[MAXNAMELEN]; 222 char zone_importance[MAXNAMELEN]; 223 }; 224 225 struct zone_mcaptab { 226 char zone_physmem_cap[MAXNAMELEN]; 227 }; 228 229 struct zone_pkgtab { 230 char zone_pkg_name[MAXNAMELEN]; 231 char zone_pkg_version[ZONE_PKG_VERSMAX]; 232 }; 233 234 struct zone_patchtab { 235 char zone_patch_id[MAXNAMELEN]; 236 }; 237 238 struct zone_devpermtab { 239 char zone_devperm_name[MAXPATHLEN]; 240 uid_t zone_devperm_uid; 241 gid_t zone_devperm_gid; 242 mode_t zone_devperm_mode; 243 char *zone_devperm_acl; 244 }; 245 246 typedef struct { 247 uu_avl_node_t zpe_entry; 248 char *zpe_name; 249 char *zpe_vers; 250 uu_avl_t *zpe_patches_avl; 251 } zone_pkg_entry_t; 252 253 typedef enum zone_iptype { 254 ZS_SHARED, 255 ZS_EXCLUSIVE 256 } zone_iptype_t; 257 258 /* 259 * Basic configuration management routines. 260 */ 261 extern zone_dochandle_t zonecfg_init_handle(void); 262 extern int zonecfg_get_handle(const char *, zone_dochandle_t); 263 extern int zonecfg_get_snapshot_handle(const char *, zone_dochandle_t); 264 extern int zonecfg_get_template_handle(const char *, const char *, 265 zone_dochandle_t); 266 extern int zonecfg_get_xml_handle(const char *, zone_dochandle_t); 267 extern int zonecfg_check_handle(zone_dochandle_t); 268 extern void zonecfg_fini_handle(zone_dochandle_t); 269 extern int zonecfg_destroy(const char *, boolean_t); 270 extern int zonecfg_destroy_snapshot(const char *); 271 extern int zonecfg_save(zone_dochandle_t); 272 extern int zonecfg_create_snapshot(const char *); 273 extern char *zonecfg_strerror(int); 274 extern int zonecfg_access(const char *, int); 275 extern void zonecfg_set_root(const char *); 276 extern const char *zonecfg_get_root(void); 277 extern boolean_t zonecfg_in_alt_root(void); 278 extern int zonecfg_num_resources(zone_dochandle_t, char *); 279 extern int zonecfg_del_all_resources(zone_dochandle_t, char *); 280 extern boolean_t zonecfg_valid_ncpus(char *, char *); 281 extern boolean_t zonecfg_valid_importance(char *); 282 extern int zonecfg_str_to_bytes(char *, uint64_t *); 283 extern boolean_t zonecfg_valid_memlimit(char *, uint64_t *); 284 extern boolean_t zonecfg_valid_alias_limit(char *, char *, uint64_t *); 285 286 /* 287 * Zone name, path to zone directory, autoboot setting, pool, boot 288 * arguments, and scheduling-class. 289 */ 290 extern int zonecfg_validate_zonename(const char *); 291 extern int zonecfg_get_name(zone_dochandle_t, char *, size_t); 292 extern int zonecfg_set_name(zone_dochandle_t, char *); 293 extern int zonecfg_get_zonepath(zone_dochandle_t, char *, size_t); 294 extern int zonecfg_set_zonepath(zone_dochandle_t, char *); 295 extern int zonecfg_get_autoboot(zone_dochandle_t, boolean_t *); 296 extern int zonecfg_set_autoboot(zone_dochandle_t, boolean_t); 297 extern int zonecfg_get_iptype(zone_dochandle_t, zone_iptype_t *); 298 extern int zonecfg_set_iptype(zone_dochandle_t, zone_iptype_t); 299 extern int zonecfg_get_pool(zone_dochandle_t, char *, size_t); 300 extern int zonecfg_set_pool(zone_dochandle_t, char *); 301 extern int zonecfg_get_bootargs(zone_dochandle_t, char *, size_t); 302 extern int zonecfg_set_bootargs(zone_dochandle_t, char *); 303 extern int zonecfg_get_sched_class(zone_dochandle_t, char *, size_t); 304 extern int zonecfg_set_sched(zone_dochandle_t, char *); 305 extern int zonecfg_get_dflt_sched_class(zone_dochandle_t, char *, int); 306 307 /* 308 * Set/retrieve the brand for the zone 309 */ 310 extern int zonecfg_get_brand(zone_dochandle_t, char *, size_t); 311 extern int zonecfg_set_brand(zone_dochandle_t, char *); 312 313 /* 314 * Filesystem configuration. 315 */ 316 extern int zonecfg_add_filesystem(zone_dochandle_t, struct zone_fstab *); 317 extern int zonecfg_delete_filesystem(zone_dochandle_t, 318 struct zone_fstab *); 319 extern int zonecfg_modify_filesystem(zone_dochandle_t, 320 struct zone_fstab *, struct zone_fstab *); 321 extern int zonecfg_lookup_filesystem(zone_dochandle_t, 322 struct zone_fstab *); 323 extern int zonecfg_add_ipd(zone_dochandle_t, struct zone_fstab *); 324 extern int zonecfg_delete_ipd(zone_dochandle_t, struct zone_fstab *); 325 extern int zonecfg_modify_ipd(zone_dochandle_t, 326 struct zone_fstab *, struct zone_fstab *); 327 extern int zonecfg_lookup_ipd(zone_dochandle_t, struct zone_fstab *); 328 extern int zonecfg_add_fs_option(struct zone_fstab *, char *); 329 extern int zonecfg_remove_fs_option(struct zone_fstab *, char *); 330 extern void zonecfg_free_fs_option_list(zone_fsopt_t *); 331 extern int zonecfg_find_mounts(char *, int(*)(const char *, void *), 332 void *); 333 334 /* 335 * Network interface configuration. 336 */ 337 extern int zonecfg_add_nwif(zone_dochandle_t, struct zone_nwiftab *); 338 extern int zonecfg_delete_nwif(zone_dochandle_t, struct zone_nwiftab *); 339 extern int zonecfg_modify_nwif(zone_dochandle_t, struct zone_nwiftab *, 340 struct zone_nwiftab *); 341 extern int zonecfg_lookup_nwif(zone_dochandle_t, struct zone_nwiftab *); 342 343 /* 344 * Hostid emulation configuration. 345 */ 346 extern int zonecfg_get_hostid(zone_dochandle_t, char *, size_t); 347 extern int zonecfg_set_hostid(zone_dochandle_t, const char *); 348 extern int zonecfg_valid_hostid(const char *); 349 350 /* 351 * Device configuration and rule matching. 352 */ 353 extern int zonecfg_add_dev(zone_dochandle_t, struct zone_devtab *); 354 extern int zonecfg_delete_dev(zone_dochandle_t, struct zone_devtab *); 355 extern int zonecfg_modify_dev(zone_dochandle_t, struct zone_devtab *, 356 struct zone_devtab *); 357 extern int zonecfg_lookup_dev(zone_dochandle_t, struct zone_devtab *); 358 359 /* 360 * Resource control configuration. 361 */ 362 extern int zonecfg_add_rctl(zone_dochandle_t, struct zone_rctltab *); 363 extern int zonecfg_delete_rctl(zone_dochandle_t, struct zone_rctltab *); 364 extern int zonecfg_modify_rctl(zone_dochandle_t, struct zone_rctltab *, 365 struct zone_rctltab *); 366 extern int zonecfg_lookup_rctl(zone_dochandle_t, struct zone_rctltab *); 367 extern int zonecfg_add_rctl_value(struct zone_rctltab *, 368 struct zone_rctlvaltab *); 369 extern int zonecfg_remove_rctl_value(struct zone_rctltab *, 370 struct zone_rctlvaltab *); 371 extern void zonecfg_free_rctl_value_list(struct zone_rctlvaltab *); 372 extern boolean_t zonecfg_aliased_rctl_ok(zone_dochandle_t, char *); 373 extern int zonecfg_set_aliased_rctl(zone_dochandle_t, char *, uint64_t); 374 extern int zonecfg_get_aliased_rctl(zone_dochandle_t, char *, uint64_t *); 375 extern int zonecfg_rm_aliased_rctl(zone_dochandle_t, char *); 376 extern int zonecfg_apply_rctls(char *, zone_dochandle_t); 377 378 /* 379 * Generic attribute configuration and type/value extraction. 380 */ 381 extern int zonecfg_add_attr(zone_dochandle_t, struct zone_attrtab *); 382 extern int zonecfg_delete_attr(zone_dochandle_t, struct zone_attrtab *); 383 extern int zonecfg_modify_attr(zone_dochandle_t, struct zone_attrtab *, 384 struct zone_attrtab *); 385 extern int zonecfg_lookup_attr(zone_dochandle_t, struct zone_attrtab *); 386 extern int zonecfg_get_attr_boolean(const struct zone_attrtab *, 387 boolean_t *); 388 extern int zonecfg_get_attr_int(const struct zone_attrtab *, int64_t *); 389 extern int zonecfg_get_attr_string(const struct zone_attrtab *, char *, 390 size_t); 391 extern int zonecfg_get_attr_uint(const struct zone_attrtab *, uint64_t *); 392 393 /* 394 * ZFS configuration. 395 */ 396 extern int zonecfg_add_ds(zone_dochandle_t, struct zone_dstab *); 397 extern int zonecfg_delete_ds(zone_dochandle_t, struct zone_dstab *); 398 extern int zonecfg_modify_ds(zone_dochandle_t, struct zone_dstab *, 399 struct zone_dstab *); 400 extern int zonecfg_lookup_ds(zone_dochandle_t, struct zone_dstab *); 401 402 /* 403 * cpu-set configuration. 404 */ 405 extern int zonecfg_add_pset(zone_dochandle_t, struct zone_psettab *); 406 extern int zonecfg_delete_pset(zone_dochandle_t); 407 extern int zonecfg_modify_pset(zone_dochandle_t, struct zone_psettab *); 408 extern int zonecfg_lookup_pset(zone_dochandle_t, struct zone_psettab *); 409 410 /* 411 * mem-cap configuration. 412 */ 413 extern int zonecfg_delete_mcap(zone_dochandle_t); 414 extern int zonecfg_modify_mcap(zone_dochandle_t, struct zone_mcaptab *); 415 extern int zonecfg_lookup_mcap(zone_dochandle_t, struct zone_mcaptab *); 416 417 /* 418 * Temporary pool support functions. 419 */ 420 extern int zonecfg_destroy_tmp_pool(char *, char *, int); 421 extern int zonecfg_bind_tmp_pool(zone_dochandle_t, zoneid_t, char *, int); 422 extern int zonecfg_bind_pool(zone_dochandle_t, zoneid_t, char *, int); 423 extern boolean_t zonecfg_warn_poold(zone_dochandle_t); 424 425 /* 426 * Miscellaneous utility functions. 427 */ 428 extern int zonecfg_enable_rcapd(char *, int); 429 430 /* 431 * attach/detach support. 432 */ 433 extern int zonecfg_get_attach_handle(const char *, const char *, 434 const char *, boolean_t, zone_dochandle_t); 435 extern int zonecfg_attach_manifest(int, zone_dochandle_t, 436 zone_dochandle_t); 437 extern int zonecfg_detach_save(zone_dochandle_t, uint_t); 438 extern boolean_t zonecfg_detached(const char *); 439 extern void zonecfg_rm_detached(zone_dochandle_t, boolean_t forced); 440 extern int zonecfg_dev_manifest(zone_dochandle_t); 441 extern int zonecfg_devperms_apply(zone_dochandle_t, const char *, 442 uid_t, gid_t, mode_t, const char *); 443 extern void zonecfg_set_swinv(zone_dochandle_t); 444 extern int zonecfg_add_pkg(zone_dochandle_t, char *, char *); 445 extern int zonecfg_add_patch(zone_dochandle_t, char *, void **); 446 extern int zonecfg_add_patch_obs(char *, void *); 447 448 /* 449 * External zone verification support. 450 */ 451 extern int zonecfg_verify_save(zone_dochandle_t, char *); 452 453 /* 454 * '*ent' iterator routines. 455 */ 456 extern int zonecfg_setfsent(zone_dochandle_t); 457 extern int zonecfg_getfsent(zone_dochandle_t, struct zone_fstab *); 458 extern int zonecfg_endfsent(zone_dochandle_t); 459 extern int zonecfg_setipdent(zone_dochandle_t); 460 extern int zonecfg_getipdent(zone_dochandle_t, struct zone_fstab *); 461 extern int zonecfg_endipdent(zone_dochandle_t); 462 extern int zonecfg_setnwifent(zone_dochandle_t); 463 extern int zonecfg_getnwifent(zone_dochandle_t, struct zone_nwiftab *); 464 extern int zonecfg_endnwifent(zone_dochandle_t); 465 extern int zonecfg_setdevent(zone_dochandle_t); 466 extern int zonecfg_getdevent(zone_dochandle_t, struct zone_devtab *); 467 extern int zonecfg_enddevent(zone_dochandle_t); 468 extern int zonecfg_setattrent(zone_dochandle_t); 469 extern int zonecfg_getattrent(zone_dochandle_t, struct zone_attrtab *); 470 extern int zonecfg_endattrent(zone_dochandle_t); 471 extern int zonecfg_setrctlent(zone_dochandle_t); 472 extern int zonecfg_getrctlent(zone_dochandle_t, struct zone_rctltab *); 473 extern int zonecfg_endrctlent(zone_dochandle_t); 474 extern int zonecfg_setdsent(zone_dochandle_t); 475 extern int zonecfg_getdsent(zone_dochandle_t, struct zone_dstab *); 476 extern int zonecfg_enddsent(zone_dochandle_t); 477 extern int zonecfg_getpsetent(zone_dochandle_t, struct zone_psettab *); 478 extern int zonecfg_getmcapent(zone_dochandle_t, struct zone_mcaptab *); 479 extern int zonecfg_getpkgdata(zone_dochandle_t, uu_avl_pool_t *, 480 uu_avl_t *); 481 extern int zonecfg_setdevperment(zone_dochandle_t); 482 extern int zonecfg_getdevperment(zone_dochandle_t, 483 struct zone_devpermtab *); 484 extern int zonecfg_enddevperment(zone_dochandle_t); 485 486 /* 487 * Privilege-related functions. 488 */ 489 extern int zonecfg_default_privset(priv_set_t *, const char *); 490 extern int zonecfg_get_privset(zone_dochandle_t, priv_set_t *, 491 char **); 492 extern int zonecfg_get_limitpriv(zone_dochandle_t, char **); 493 extern int zonecfg_set_limitpriv(zone_dochandle_t, char *); 494 495 /* 496 * Higher-level routines. 497 */ 498 extern int zone_get_brand(char *, char *, size_t); 499 extern int zone_get_rootpath(char *, char *, size_t); 500 extern int zone_get_devroot(char *, char *, size_t); 501 extern int zone_get_zonepath(char *, char *, size_t); 502 extern int zone_get_state(char *, zone_state_t *); 503 extern int zone_set_state(char *, zone_state_t); 504 extern char *zone_state_str(zone_state_t); 505 extern int zonecfg_get_name_by_uuid(const uuid_t, char *, size_t); 506 extern int zonecfg_get_uuid(const char *, uuid_t); 507 extern int zonecfg_default_brand(char *, size_t); 508 509 /* 510 * Iterator for configured zones. 511 */ 512 extern FILE *setzoneent(void); 513 extern char *getzoneent(FILE *); 514 extern struct zoneent *getzoneent_private(FILE *); 515 extern void endzoneent(FILE *); 516 517 /* 518 * File-system-related convenience functions. 519 */ 520 extern boolean_t zonecfg_valid_fs_type(const char *); 521 522 /* 523 * Network-related convenience functions. 524 */ 525 extern boolean_t zonecfg_same_net_address(char *, char *); 526 extern int zonecfg_valid_net_address(char *, struct lifreq *); 527 extern boolean_t zonecfg_ifname_exists(sa_family_t, char *); 528 529 /* 530 * Rctl-related common functions. 531 */ 532 extern boolean_t zonecfg_is_rctl(const char *); 533 extern boolean_t zonecfg_valid_rctlname(const char *); 534 extern boolean_t zonecfg_valid_rctlblk(const rctlblk_t *); 535 extern boolean_t zonecfg_valid_rctl(const char *, const rctlblk_t *); 536 extern int zonecfg_construct_rctlblk(const struct zone_rctlvaltab *, 537 rctlblk_t *); 538 539 /* 540 * Live Upgrade support functions. Shared between ON and install gate. 541 */ 542 extern FILE *zonecfg_open_scratch(const char *, boolean_t); 543 extern int zonecfg_lock_scratch(FILE *); 544 extern void zonecfg_close_scratch(FILE *); 545 extern int zonecfg_get_scratch(FILE *, char *, size_t, char *, size_t, char *, 546 size_t); 547 extern int zonecfg_find_scratch(FILE *, const char *, const char *, char *, 548 size_t); 549 extern int zonecfg_reverse_scratch(FILE *, const char *, char *, size_t, 550 char *, size_t); 551 extern int zonecfg_add_scratch(FILE *, const char *, const char *, 552 const char *); 553 extern int zonecfg_delete_scratch(FILE *, const char *); 554 extern boolean_t zonecfg_is_scratch(const char *); 555 556 /* 557 * zoneadmd support functions. Shared between zoneadm and brand hook code. 558 */ 559 extern void zonecfg_init_lock_file(const char *, char **); 560 extern void zonecfg_release_lock_file(const char *, int); 561 extern int zonecfg_grab_lock_file(const char *, int *); 562 extern boolean_t zonecfg_lock_file_held(int *); 563 extern int zonecfg_ping_zoneadmd(const char *); 564 extern int zonecfg_call_zoneadmd(const char *, zone_cmd_arg_t *, char *, 565 boolean_t); 566 567 #ifdef __cplusplus 568 } 569 #endif 570 571 #endif /* _LIBZONECFG_H */ 572