17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5ee519a1fSgjelinek * Common Development and Distribution License (the "License"). 6ee519a1fSgjelinek * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21ffbafc53Scomay 227c478bd9Sstevel@tonic-gate /* 23a20ee416SGlenn Faden * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _LIBZONECFG_H 277c478bd9Sstevel@tonic-gate #define _LIBZONECFG_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Zone configuration header file. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* sys/socket.h is required by net/if.h, which has a constant needed here */ 387c478bd9Sstevel@tonic-gate #include <sys/param.h> 397c478bd9Sstevel@tonic-gate #include <sys/fstyp.h> 407c478bd9Sstevel@tonic-gate #include <sys/mount.h> 417c478bd9Sstevel@tonic-gate #include <priv.h> 427c478bd9Sstevel@tonic-gate #include <netinet/in.h> 437c478bd9Sstevel@tonic-gate #include <sys/socket.h> 447c478bd9Sstevel@tonic-gate #include <net/if.h> 457c478bd9Sstevel@tonic-gate #include <stdio.h> 467c478bd9Sstevel@tonic-gate #include <rctl.h> 477c478bd9Sstevel@tonic-gate #include <zone.h> 489acbbeafSnn35248 #include <libbrand.h> 49108322fbScarlsonj #include <sys/uuid.h> 506cfd72c6Sgjelinek #include <libuutil.h> 510094b373Sjv227347 #include <sys/mnttab.h> 52cb8a054bSGlenn Faden #include <limits.h> 53cb8a054bSGlenn Faden #include <utmpx.h> 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #define ZONE_ID_UNDEFINED -1 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate #define Z_OK 0 587c478bd9Sstevel@tonic-gate #define Z_EMPTY_DOCUMENT 1 /* XML doc root element is null */ 597c478bd9Sstevel@tonic-gate #define Z_WRONG_DOC_TYPE 2 /* top-level XML doc element != zone */ 607c478bd9Sstevel@tonic-gate #define Z_BAD_PROPERTY 3 /* libxml-level property problem */ 617c478bd9Sstevel@tonic-gate #define Z_TEMP_FILE 4 /* problem creating temporary file */ 627c478bd9Sstevel@tonic-gate #define Z_SAVING_FILE 5 /* libxml error saving or validating */ 637c478bd9Sstevel@tonic-gate #define Z_NO_ENTRY 6 /* no such entry */ 647c478bd9Sstevel@tonic-gate #define Z_BOGUS_ZONE_NAME 7 /* illegal zone name */ 657c478bd9Sstevel@tonic-gate #define Z_REQD_RESOURCE_MISSING 8 /* required resource missing */ 667c478bd9Sstevel@tonic-gate #define Z_REQD_PROPERTY_MISSING 9 /* required property missing */ 677c478bd9Sstevel@tonic-gate #define Z_BAD_HANDLE 10 /* bad document handle */ 687c478bd9Sstevel@tonic-gate #define Z_NOMEM 11 /* out of memory (like ENOMEM) */ 697c478bd9Sstevel@tonic-gate #define Z_INVAL 12 /* invalid argument (like EINVAL) */ 707c478bd9Sstevel@tonic-gate #define Z_ACCES 13 /* permission denied (like EACCES) */ 717c478bd9Sstevel@tonic-gate #define Z_TOO_BIG 14 /* string won't fit in char array */ 727c478bd9Sstevel@tonic-gate #define Z_MISC_FS 15 /* miscellaneous file-system error */ 737c478bd9Sstevel@tonic-gate #define Z_NO_ZONE 16 /* no such zone */ 747c478bd9Sstevel@tonic-gate #define Z_NO_RESOURCE_TYPE 17 /* no/wrong resource type */ 757c478bd9Sstevel@tonic-gate #define Z_NO_RESOURCE_ID 18 /* no/wrong resource id */ 767c478bd9Sstevel@tonic-gate #define Z_NO_PROPERTY_TYPE 19 /* no/wrong property type */ 777c478bd9Sstevel@tonic-gate #define Z_NO_PROPERTY_ID 20 /* no/wrong property id */ 78087719fdSdp #define Z_BAD_ZONE_STATE 21 /* zone state invalid for given task */ 797c478bd9Sstevel@tonic-gate #define Z_INVALID_DOCUMENT 22 /* libxml can't validate against DTD */ 80087719fdSdp #define Z_NAME_IN_USE 23 /* zone name already in use (rename) */ 817c478bd9Sstevel@tonic-gate #define Z_NO_SUCH_ID 24 /* delete_index: no old ID */ 827c478bd9Sstevel@tonic-gate #define Z_UPDATING_INDEX 25 /* add/modify/delete_index problem */ 837c478bd9Sstevel@tonic-gate #define Z_LOCKING_FILE 26 /* problem locking index file */ 847c478bd9Sstevel@tonic-gate #define Z_UNLOCKING_FILE 27 /* problem unlocking index file */ 857c478bd9Sstevel@tonic-gate #define Z_SYSTEM 28 /* consult errno instead */ 867c478bd9Sstevel@tonic-gate #define Z_INSUFFICIENT_SPEC 29 /* resource insufficiently specified */ 877c478bd9Sstevel@tonic-gate #define Z_RESOLVED_PATH 34 /* resolved path mismatch */ 887c478bd9Sstevel@tonic-gate #define Z_IPV6_ADDR_PREFIX_LEN 35 /* IPv6 address prefix length needed */ 897c478bd9Sstevel@tonic-gate #define Z_BOGUS_ADDRESS 36 /* not IPv[4|6] address or host name */ 90ffbafc53Scomay #define Z_PRIV_PROHIBITED 37 /* specified privilege is prohibited */ 91ffbafc53Scomay #define Z_PRIV_REQUIRED 38 /* required privilege is missing */ 92ffbafc53Scomay #define Z_PRIV_UNKNOWN 39 /* specified privilege is unknown */ 939acbbeafSnn35248 #define Z_BRAND_ERROR 40 /* brand-specific error */ 940209230bSgjelinek #define Z_INCOMPATIBLE 41 /* incompatible settings */ 950209230bSgjelinek #define Z_ALIAS_DISALLOW 42 /* rctl alias disallowed */ 960209230bSgjelinek #define Z_CLEAR_DISALLOW 43 /* clear property disallowed */ 970209230bSgjelinek #define Z_POOL 44 /* generic libpool error */ 980209230bSgjelinek #define Z_POOLS_NOT_ACTIVE 45 /* pool service not enabled */ 990209230bSgjelinek #define Z_POOL_ENABLE 46 /* pools enable failed */ 1000209230bSgjelinek #define Z_NO_POOL 47 /* no such pool configured */ 1010209230bSgjelinek #define Z_POOL_CREATE 48 /* pool create failed */ 1020209230bSgjelinek #define Z_POOL_BIND 49 /* pool bind failed */ 1030fbb751dSJohn Levon #define Z_INVALID_PROPERTY 50 /* invalid property value */ 1047c478bd9Sstevel@tonic-gate 1053e9f28f0Scarlsonj /* 1063e9f28f0Scarlsonj * Warning: these are shared with the admin/install consolidation. 1073e9f28f0Scarlsonj * Do not insert states between any of the currently defined states, 1083e9f28f0Scarlsonj * and any new states must be evaluated for impact on range comparisons. 1093e9f28f0Scarlsonj */ 1107c478bd9Sstevel@tonic-gate #define ZONE_STATE_CONFIGURED 0 1117c478bd9Sstevel@tonic-gate #define ZONE_STATE_INCOMPLETE 1 1127c478bd9Sstevel@tonic-gate #define ZONE_STATE_INSTALLED 2 1137c478bd9Sstevel@tonic-gate #define ZONE_STATE_READY 3 1143e9f28f0Scarlsonj #define ZONE_STATE_RUNNING 4 1153e9f28f0Scarlsonj #define ZONE_STATE_SHUTTING_DOWN 5 1163e9f28f0Scarlsonj #define ZONE_STATE_DOWN 6 1173e9f28f0Scarlsonj #define ZONE_STATE_MOUNTED 7 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #define ZONE_STATE_MAXSTRLEN 14 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate #define LIBZONECFG_PATH "libzonecfg.so.1" 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #define ZONE_CONFIG_ROOT "/etc/zones" 1247c478bd9Sstevel@tonic-gate #define ZONE_INDEX_FILE ZONE_CONFIG_ROOT "/index" 1257c478bd9Sstevel@tonic-gate 126cb8a054bSGlenn Faden #define MAXUSERNAME (sizeof (((struct utmpx *)0)->ut_name)) 127cb8a054bSGlenn Faden #define MAXAUTHS 4096 128cb8a054bSGlenn Faden #define ZONE_MGMT_PROF "Zone Management" 129cb8a054bSGlenn Faden 130555afedfScarlsonj /* Owner, group, and mode (defined by packaging) for the config directory */ 131555afedfScarlsonj #define ZONE_CONFIG_UID 0 /* root */ 132555afedfScarlsonj #define ZONE_CONFIG_GID 3 /* sys */ 133555afedfScarlsonj #define ZONE_CONFIG_MODE 0755 134555afedfScarlsonj 135555afedfScarlsonj /* Owner, group, and mode (defined by packaging) for the index file */ 136555afedfScarlsonj #define ZONE_INDEX_UID 0 /* root */ 137555afedfScarlsonj #define ZONE_INDEX_GID 3 /* sys */ 138555afedfScarlsonj #define ZONE_INDEX_MODE 0644 139555afedfScarlsonj 140ee519a1fSgjelinek /* The maximum length of the VERSION string in the pkginfo(4) file. */ 141ee519a1fSgjelinek #define ZONE_PKG_VERSMAX 256 142ee519a1fSgjelinek 1437c478bd9Sstevel@tonic-gate /* 1440209230bSgjelinek * Shortened alias names for the zones rctls. 1450209230bSgjelinek */ 1460209230bSgjelinek #define ALIAS_MAXLWPS "max-lwps" 1470209230bSgjelinek #define ALIAS_MAXSHMMEM "max-shm-memory" 1480209230bSgjelinek #define ALIAS_MAXSHMIDS "max-shm-ids" 1490209230bSgjelinek #define ALIAS_MAXMSGIDS "max-msg-ids" 1500209230bSgjelinek #define ALIAS_MAXSEMIDS "max-sem-ids" 1510209230bSgjelinek #define ALIAS_MAXLOCKEDMEM "locked" 1520209230bSgjelinek #define ALIAS_MAXSWAP "swap" 1530209230bSgjelinek #define ALIAS_SHARES "cpu-shares" 154c97ad5cdSakolb #define ALIAS_CPUCAP "cpu-cap" 155ff19e029SMenno Lageman #define ALIAS_MAXPROCS "max-processes" 1560209230bSgjelinek 15716ab8c7bSgjelinek /* Default name for zone detached manifest */ 15816ab8c7bSgjelinek #define ZONE_DETACHED "SUNWdetached.xml" 15916ab8c7bSgjelinek 1600209230bSgjelinek /* 1618cd327d5Sgjelinek * Bit flag definitions for passing into libzonecfg functions. 1628cd327d5Sgjelinek */ 1638cd327d5Sgjelinek #define ZONE_DRY_RUN 0x01 1648cd327d5Sgjelinek 1658cd327d5Sgjelinek /* 1667c478bd9Sstevel@tonic-gate * The integer field expresses the current values on a get. 1677c478bd9Sstevel@tonic-gate * On a put, it represents the new values if >= 0 or "don't change" if < 0. 1687c478bd9Sstevel@tonic-gate */ 1697c478bd9Sstevel@tonic-gate struct zoneent { 1707c478bd9Sstevel@tonic-gate char zone_name[ZONENAME_MAX]; /* name of the zone */ 1717c478bd9Sstevel@tonic-gate int zone_state; /* configured | incomplete | installed */ 172108322fbScarlsonj char zone_path[MAXPATHLEN]; /* path to zone storage */ 173108322fbScarlsonj uuid_t zone_uuid; /* unique ID for zone */ 174087719fdSdp char zone_newname[ZONENAME_MAX]; /* for doing renames */ 1757c478bd9Sstevel@tonic-gate }; 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate typedef struct zone_dochandle *zone_dochandle_t; /* opaque handle */ 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate typedef uint_t zone_state_t; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate typedef struct zone_fsopt { 1827c478bd9Sstevel@tonic-gate struct zone_fsopt *zone_fsopt_next; 1837c478bd9Sstevel@tonic-gate char zone_fsopt_opt[MAX_MNTOPT_STR]; 1847c478bd9Sstevel@tonic-gate } zone_fsopt_t; 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate struct zone_fstab { 1877c478bd9Sstevel@tonic-gate char zone_fs_special[MAXPATHLEN]; /* special file */ 1887c478bd9Sstevel@tonic-gate char zone_fs_dir[MAXPATHLEN]; /* mount point */ 1897c478bd9Sstevel@tonic-gate char zone_fs_type[FSTYPSZ]; /* e.g. ufs */ 1907c478bd9Sstevel@tonic-gate zone_fsopt_t *zone_fs_options; /* mount options */ 1917c478bd9Sstevel@tonic-gate char zone_fs_raw[MAXPATHLEN]; /* device to fsck */ 1927c478bd9Sstevel@tonic-gate }; 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate struct zone_nwiftab { 195*550b6e40SSowmini Varadhan char zone_nwif_address[INET6_ADDRSTRLEN]; /* shared-ip only */ 196*550b6e40SSowmini Varadhan char zone_nwif_allowed_address[INET6_ADDRSTRLEN]; /* excl-ip only */ 1977c478bd9Sstevel@tonic-gate char zone_nwif_physical[LIFNAMSIZ]; 198de860bd9Sgfaden char zone_nwif_defrouter[INET6_ADDRSTRLEN]; 1997c478bd9Sstevel@tonic-gate }; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate struct zone_devtab { 2027c478bd9Sstevel@tonic-gate char zone_dev_match[MAXPATHLEN]; 2037c478bd9Sstevel@tonic-gate }; 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate struct zone_rctlvaltab { 2067c478bd9Sstevel@tonic-gate char zone_rctlval_priv[MAXNAMELEN]; 2077c478bd9Sstevel@tonic-gate char zone_rctlval_limit[MAXNAMELEN]; 2087c478bd9Sstevel@tonic-gate char zone_rctlval_action[MAXNAMELEN]; 2097c478bd9Sstevel@tonic-gate struct zone_rctlvaltab *zone_rctlval_next; 2107c478bd9Sstevel@tonic-gate }; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate struct zone_rctltab { 2137c478bd9Sstevel@tonic-gate char zone_rctl_name[MAXNAMELEN]; 2147c478bd9Sstevel@tonic-gate struct zone_rctlvaltab *zone_rctl_valptr; 2157c478bd9Sstevel@tonic-gate }; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate struct zone_attrtab { 2187c478bd9Sstevel@tonic-gate char zone_attr_name[MAXNAMELEN]; 2197c478bd9Sstevel@tonic-gate char zone_attr_type[MAXNAMELEN]; 2207c478bd9Sstevel@tonic-gate char zone_attr_value[2 * BUFSIZ]; 2217c478bd9Sstevel@tonic-gate }; 2227c478bd9Sstevel@tonic-gate 223fa9e4066Sahrens struct zone_dstab { 224fa9e4066Sahrens char zone_dataset_name[MAXNAMELEN]; 225fa9e4066Sahrens }; 226fa9e4066Sahrens 2270209230bSgjelinek struct zone_psettab { 2280209230bSgjelinek char zone_ncpu_min[MAXNAMELEN]; 2290209230bSgjelinek char zone_ncpu_max[MAXNAMELEN]; 2300209230bSgjelinek char zone_importance[MAXNAMELEN]; 2310209230bSgjelinek }; 2320209230bSgjelinek 2330209230bSgjelinek struct zone_mcaptab { 2340209230bSgjelinek char zone_physmem_cap[MAXNAMELEN]; 2350209230bSgjelinek }; 2360209230bSgjelinek 237ee519a1fSgjelinek struct zone_pkgtab { 238ee519a1fSgjelinek char zone_pkg_name[MAXNAMELEN]; 239ee519a1fSgjelinek char zone_pkg_version[ZONE_PKG_VERSMAX]; 240ee519a1fSgjelinek }; 241ee519a1fSgjelinek 242ee519a1fSgjelinek struct zone_devpermtab { 243ee519a1fSgjelinek char zone_devperm_name[MAXPATHLEN]; 244ee519a1fSgjelinek uid_t zone_devperm_uid; 245ee519a1fSgjelinek gid_t zone_devperm_gid; 246ee519a1fSgjelinek mode_t zone_devperm_mode; 247ee519a1fSgjelinek char *zone_devperm_acl; 248ee519a1fSgjelinek }; 249ee519a1fSgjelinek 250cb8a054bSGlenn Faden struct zone_admintab { 251cb8a054bSGlenn Faden char zone_admin_user[MAXUSERNAME]; 252cb8a054bSGlenn Faden char zone_admin_auths[MAXAUTHS]; 253cb8a054bSGlenn Faden }; 254cb8a054bSGlenn Faden 255cb8a054bSGlenn Faden typedef struct zone_userauths { 256cb8a054bSGlenn Faden char user[MAXUSERNAME]; 257cb8a054bSGlenn Faden char zonename[ZONENAME_MAX]; 258cb8a054bSGlenn Faden struct zone_userauths *next; 259cb8a054bSGlenn Faden } zone_userauths_t; 260cb8a054bSGlenn Faden 2616cfd72c6Sgjelinek typedef struct { 2626cfd72c6Sgjelinek uu_avl_node_t zpe_entry; 2636cfd72c6Sgjelinek char *zpe_name; 2646cfd72c6Sgjelinek char *zpe_vers; 2656cfd72c6Sgjelinek } zone_pkg_entry_t; 2666cfd72c6Sgjelinek 267f4b3ec61Sdh155122 typedef enum zone_iptype { 268f4b3ec61Sdh155122 ZS_SHARED, 269f4b3ec61Sdh155122 ZS_EXCLUSIVE 270f4b3ec61Sdh155122 } zone_iptype_t; 271f4b3ec61Sdh155122 2727c478bd9Sstevel@tonic-gate /* 2737c478bd9Sstevel@tonic-gate * Basic configuration management routines. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate extern zone_dochandle_t zonecfg_init_handle(void); 276108322fbScarlsonj extern int zonecfg_get_handle(const char *, zone_dochandle_t); 277108322fbScarlsonj extern int zonecfg_get_snapshot_handle(const char *, zone_dochandle_t); 278108322fbScarlsonj extern int zonecfg_get_template_handle(const char *, const char *, 279108322fbScarlsonj zone_dochandle_t); 2809acbbeafSnn35248 extern int zonecfg_get_xml_handle(const char *, zone_dochandle_t); 2817c478bd9Sstevel@tonic-gate extern int zonecfg_check_handle(zone_dochandle_t); 2827c478bd9Sstevel@tonic-gate extern void zonecfg_fini_handle(zone_dochandle_t); 283087719fdSdp extern int zonecfg_destroy(const char *, boolean_t); 284108322fbScarlsonj extern int zonecfg_destroy_snapshot(const char *); 2857c478bd9Sstevel@tonic-gate extern int zonecfg_save(zone_dochandle_t); 286108322fbScarlsonj extern int zonecfg_create_snapshot(const char *); 2877c478bd9Sstevel@tonic-gate extern char *zonecfg_strerror(int); 2887c478bd9Sstevel@tonic-gate extern int zonecfg_access(const char *, int); 289108322fbScarlsonj extern void zonecfg_set_root(const char *); 290108322fbScarlsonj extern const char *zonecfg_get_root(void); 291108322fbScarlsonj extern boolean_t zonecfg_in_alt_root(void); 2920209230bSgjelinek extern int zonecfg_num_resources(zone_dochandle_t, char *); 2930209230bSgjelinek extern int zonecfg_del_all_resources(zone_dochandle_t, char *); 2940209230bSgjelinek extern boolean_t zonecfg_valid_ncpus(char *, char *); 2950209230bSgjelinek extern boolean_t zonecfg_valid_importance(char *); 2960209230bSgjelinek extern int zonecfg_str_to_bytes(char *, uint64_t *); 2970209230bSgjelinek extern boolean_t zonecfg_valid_memlimit(char *, uint64_t *); 2980209230bSgjelinek extern boolean_t zonecfg_valid_alias_limit(char *, char *, uint64_t *); 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate /* 3010209230bSgjelinek * Zone name, path to zone directory, autoboot setting, pool, boot 3020209230bSgjelinek * arguments, and scheduling-class. 3037c478bd9Sstevel@tonic-gate */ 304108322fbScarlsonj extern int zonecfg_validate_zonename(const char *); 3057c478bd9Sstevel@tonic-gate extern int zonecfg_get_name(zone_dochandle_t, char *, size_t); 3067c478bd9Sstevel@tonic-gate extern int zonecfg_set_name(zone_dochandle_t, char *); 3077c478bd9Sstevel@tonic-gate extern int zonecfg_get_zonepath(zone_dochandle_t, char *, size_t); 3087c478bd9Sstevel@tonic-gate extern int zonecfg_set_zonepath(zone_dochandle_t, char *); 3097c478bd9Sstevel@tonic-gate extern int zonecfg_get_autoboot(zone_dochandle_t, boolean_t *); 3107c478bd9Sstevel@tonic-gate extern int zonecfg_set_autoboot(zone_dochandle_t, boolean_t); 311f4b3ec61Sdh155122 extern int zonecfg_get_iptype(zone_dochandle_t, zone_iptype_t *); 312f4b3ec61Sdh155122 extern int zonecfg_set_iptype(zone_dochandle_t, zone_iptype_t); 3137c478bd9Sstevel@tonic-gate extern int zonecfg_get_pool(zone_dochandle_t, char *, size_t); 3147c478bd9Sstevel@tonic-gate extern int zonecfg_set_pool(zone_dochandle_t, char *); 3153f2f09c1Sdp extern int zonecfg_get_bootargs(zone_dochandle_t, char *, size_t); 3163f2f09c1Sdp extern int zonecfg_set_bootargs(zone_dochandle_t, char *); 3170209230bSgjelinek extern int zonecfg_get_sched_class(zone_dochandle_t, char *, size_t); 3180209230bSgjelinek extern int zonecfg_set_sched(zone_dochandle_t, char *); 3190209230bSgjelinek extern int zonecfg_get_dflt_sched_class(zone_dochandle_t, char *, int); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate /* 3229acbbeafSnn35248 * Set/retrieve the brand for the zone 3239acbbeafSnn35248 */ 3249acbbeafSnn35248 extern int zonecfg_get_brand(zone_dochandle_t, char *, size_t); 3259acbbeafSnn35248 extern int zonecfg_set_brand(zone_dochandle_t, char *); 3269acbbeafSnn35248 3279acbbeafSnn35248 /* 3287c478bd9Sstevel@tonic-gate * Filesystem configuration. 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate extern int zonecfg_add_filesystem(zone_dochandle_t, struct zone_fstab *); 3317c478bd9Sstevel@tonic-gate extern int zonecfg_delete_filesystem(zone_dochandle_t, 3327c478bd9Sstevel@tonic-gate struct zone_fstab *); 3337c478bd9Sstevel@tonic-gate extern int zonecfg_modify_filesystem(zone_dochandle_t, 3347c478bd9Sstevel@tonic-gate struct zone_fstab *, struct zone_fstab *); 3357c478bd9Sstevel@tonic-gate extern int zonecfg_lookup_filesystem(zone_dochandle_t, 3367c478bd9Sstevel@tonic-gate struct zone_fstab *); 3377c478bd9Sstevel@tonic-gate extern int zonecfg_add_fs_option(struct zone_fstab *, char *); 3387c478bd9Sstevel@tonic-gate extern int zonecfg_remove_fs_option(struct zone_fstab *, char *); 3397c478bd9Sstevel@tonic-gate extern void zonecfg_free_fs_option_list(zone_fsopt_t *); 3400094b373Sjv227347 extern int zonecfg_find_mounts(char *, int(*)(const struct mnttab *, 3410094b373Sjv227347 void *), void *); 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate /* 3447c478bd9Sstevel@tonic-gate * Network interface configuration. 3457c478bd9Sstevel@tonic-gate */ 3467c478bd9Sstevel@tonic-gate extern int zonecfg_add_nwif(zone_dochandle_t, struct zone_nwiftab *); 3477c478bd9Sstevel@tonic-gate extern int zonecfg_delete_nwif(zone_dochandle_t, struct zone_nwiftab *); 3487c478bd9Sstevel@tonic-gate extern int zonecfg_modify_nwif(zone_dochandle_t, struct zone_nwiftab *, 3497c478bd9Sstevel@tonic-gate struct zone_nwiftab *); 3507c478bd9Sstevel@tonic-gate extern int zonecfg_lookup_nwif(zone_dochandle_t, struct zone_nwiftab *); 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate /* 3535679c89fSjv227347 * Hostid emulation configuration. 3545679c89fSjv227347 */ 3555679c89fSjv227347 extern int zonecfg_get_hostid(zone_dochandle_t, char *, size_t); 3565679c89fSjv227347 extern int zonecfg_set_hostid(zone_dochandle_t, const char *); 3570fbb751dSJohn Levon 3580fbb751dSJohn Levon /* 3590fbb751dSJohn Levon * Allowed FS mounts configuration. 3600fbb751dSJohn Levon */ 3610fbb751dSJohn Levon extern int zonecfg_get_fs_allowed(zone_dochandle_t, char *, size_t); 3620fbb751dSJohn Levon extern int zonecfg_set_fs_allowed(zone_dochandle_t, const char *); 3635679c89fSjv227347 3645679c89fSjv227347 /* 3657c478bd9Sstevel@tonic-gate * Device configuration and rule matching. 3667c478bd9Sstevel@tonic-gate */ 3677c478bd9Sstevel@tonic-gate extern int zonecfg_add_dev(zone_dochandle_t, struct zone_devtab *); 3687c478bd9Sstevel@tonic-gate extern int zonecfg_delete_dev(zone_dochandle_t, struct zone_devtab *); 3697c478bd9Sstevel@tonic-gate extern int zonecfg_modify_dev(zone_dochandle_t, struct zone_devtab *, 3707c478bd9Sstevel@tonic-gate struct zone_devtab *); 3717c478bd9Sstevel@tonic-gate extern int zonecfg_lookup_dev(zone_dochandle_t, struct zone_devtab *); 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* 3747c478bd9Sstevel@tonic-gate * Resource control configuration. 3757c478bd9Sstevel@tonic-gate */ 3767c478bd9Sstevel@tonic-gate extern int zonecfg_add_rctl(zone_dochandle_t, struct zone_rctltab *); 3777c478bd9Sstevel@tonic-gate extern int zonecfg_delete_rctl(zone_dochandle_t, struct zone_rctltab *); 3787c478bd9Sstevel@tonic-gate extern int zonecfg_modify_rctl(zone_dochandle_t, struct zone_rctltab *, 3797c478bd9Sstevel@tonic-gate struct zone_rctltab *); 3807c478bd9Sstevel@tonic-gate extern int zonecfg_lookup_rctl(zone_dochandle_t, struct zone_rctltab *); 3817c478bd9Sstevel@tonic-gate extern int zonecfg_add_rctl_value(struct zone_rctltab *, 3827c478bd9Sstevel@tonic-gate struct zone_rctlvaltab *); 3837c478bd9Sstevel@tonic-gate extern int zonecfg_remove_rctl_value(struct zone_rctltab *, 3847c478bd9Sstevel@tonic-gate struct zone_rctlvaltab *); 3857c478bd9Sstevel@tonic-gate extern void zonecfg_free_rctl_value_list(struct zone_rctlvaltab *); 3860209230bSgjelinek extern boolean_t zonecfg_aliased_rctl_ok(zone_dochandle_t, char *); 3870209230bSgjelinek extern int zonecfg_set_aliased_rctl(zone_dochandle_t, char *, uint64_t); 3880209230bSgjelinek extern int zonecfg_get_aliased_rctl(zone_dochandle_t, char *, uint64_t *); 3890209230bSgjelinek extern int zonecfg_rm_aliased_rctl(zone_dochandle_t, char *); 3900209230bSgjelinek extern int zonecfg_apply_rctls(char *, zone_dochandle_t); 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate /* 3937c478bd9Sstevel@tonic-gate * Generic attribute configuration and type/value extraction. 3947c478bd9Sstevel@tonic-gate */ 3957c478bd9Sstevel@tonic-gate extern int zonecfg_add_attr(zone_dochandle_t, struct zone_attrtab *); 3967c478bd9Sstevel@tonic-gate extern int zonecfg_delete_attr(zone_dochandle_t, struct zone_attrtab *); 3977c478bd9Sstevel@tonic-gate extern int zonecfg_modify_attr(zone_dochandle_t, struct zone_attrtab *, 3987c478bd9Sstevel@tonic-gate struct zone_attrtab *); 3997c478bd9Sstevel@tonic-gate extern int zonecfg_lookup_attr(zone_dochandle_t, struct zone_attrtab *); 4007c478bd9Sstevel@tonic-gate extern int zonecfg_get_attr_boolean(const struct zone_attrtab *, 4017c478bd9Sstevel@tonic-gate boolean_t *); 4027c478bd9Sstevel@tonic-gate extern int zonecfg_get_attr_int(const struct zone_attrtab *, int64_t *); 4037c478bd9Sstevel@tonic-gate extern int zonecfg_get_attr_string(const struct zone_attrtab *, char *, 4047c478bd9Sstevel@tonic-gate size_t); 4057c478bd9Sstevel@tonic-gate extern int zonecfg_get_attr_uint(const struct zone_attrtab *, uint64_t *); 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate /* 408fa9e4066Sahrens * ZFS configuration. 409fa9e4066Sahrens */ 410fa9e4066Sahrens extern int zonecfg_add_ds(zone_dochandle_t, struct zone_dstab *); 411fa9e4066Sahrens extern int zonecfg_delete_ds(zone_dochandle_t, struct zone_dstab *); 412fa9e4066Sahrens extern int zonecfg_modify_ds(zone_dochandle_t, struct zone_dstab *, 413fa9e4066Sahrens struct zone_dstab *); 414fa9e4066Sahrens extern int zonecfg_lookup_ds(zone_dochandle_t, struct zone_dstab *); 415fa9e4066Sahrens 416fa9e4066Sahrens /* 4170209230bSgjelinek * cpu-set configuration. 4180209230bSgjelinek */ 4190209230bSgjelinek extern int zonecfg_add_pset(zone_dochandle_t, struct zone_psettab *); 4200209230bSgjelinek extern int zonecfg_delete_pset(zone_dochandle_t); 4210209230bSgjelinek extern int zonecfg_modify_pset(zone_dochandle_t, struct zone_psettab *); 4220209230bSgjelinek extern int zonecfg_lookup_pset(zone_dochandle_t, struct zone_psettab *); 4230209230bSgjelinek 4240209230bSgjelinek /* 4250209230bSgjelinek * mem-cap configuration. 4260209230bSgjelinek */ 4270209230bSgjelinek extern int zonecfg_delete_mcap(zone_dochandle_t); 4280209230bSgjelinek extern int zonecfg_modify_mcap(zone_dochandle_t, struct zone_mcaptab *); 4290209230bSgjelinek extern int zonecfg_lookup_mcap(zone_dochandle_t, struct zone_mcaptab *); 4300209230bSgjelinek 4310209230bSgjelinek /* 4320209230bSgjelinek * Temporary pool support functions. 4330209230bSgjelinek */ 4340209230bSgjelinek extern int zonecfg_destroy_tmp_pool(char *, char *, int); 4350209230bSgjelinek extern int zonecfg_bind_tmp_pool(zone_dochandle_t, zoneid_t, char *, int); 4360209230bSgjelinek extern int zonecfg_bind_pool(zone_dochandle_t, zoneid_t, char *, int); 4370209230bSgjelinek extern boolean_t zonecfg_warn_poold(zone_dochandle_t); 4380dc2366fSVenugopal Iyer extern int zonecfg_get_poolname(zone_dochandle_t, char *, char *, size_t); 4390209230bSgjelinek 4400209230bSgjelinek /* 4410209230bSgjelinek * Miscellaneous utility functions. 4420209230bSgjelinek */ 4430209230bSgjelinek extern int zonecfg_enable_rcapd(char *, int); 4440209230bSgjelinek 4450209230bSgjelinek /* 446ee519a1fSgjelinek * attach/detach support. 447ee519a1fSgjelinek */ 448ee519a1fSgjelinek extern int zonecfg_get_attach_handle(const char *, const char *, 44916ab8c7bSgjelinek const char *, boolean_t, zone_dochandle_t); 4508cd327d5Sgjelinek extern int zonecfg_attach_manifest(int, zone_dochandle_t, 4518cd327d5Sgjelinek zone_dochandle_t); 4528cd327d5Sgjelinek extern int zonecfg_detach_save(zone_dochandle_t, uint_t); 453ee519a1fSgjelinek extern boolean_t zonecfg_detached(const char *); 454ee519a1fSgjelinek extern void zonecfg_rm_detached(zone_dochandle_t, boolean_t forced); 455ff17c8bfSgjelinek extern int zonecfg_dev_manifest(zone_dochandle_t); 456ee519a1fSgjelinek extern int zonecfg_devperms_apply(zone_dochandle_t, const char *, 457ee519a1fSgjelinek uid_t, gid_t, mode_t, const char *); 458ff17c8bfSgjelinek extern void zonecfg_set_swinv(zone_dochandle_t); 459ff17c8bfSgjelinek extern int zonecfg_add_pkg(zone_dochandle_t, char *, char *); 460ee519a1fSgjelinek 4619acbbeafSnn35248 /* 4629acbbeafSnn35248 * External zone verification support. 4639acbbeafSnn35248 */ 4649acbbeafSnn35248 extern int zonecfg_verify_save(zone_dochandle_t, char *); 465ee519a1fSgjelinek 466ee519a1fSgjelinek /* 4677c478bd9Sstevel@tonic-gate * '*ent' iterator routines. 4687c478bd9Sstevel@tonic-gate */ 4697c478bd9Sstevel@tonic-gate extern int zonecfg_setfsent(zone_dochandle_t); 4707c478bd9Sstevel@tonic-gate extern int zonecfg_getfsent(zone_dochandle_t, struct zone_fstab *); 4717c478bd9Sstevel@tonic-gate extern int zonecfg_endfsent(zone_dochandle_t); 4727c478bd9Sstevel@tonic-gate extern int zonecfg_setnwifent(zone_dochandle_t); 4737c478bd9Sstevel@tonic-gate extern int zonecfg_getnwifent(zone_dochandle_t, struct zone_nwiftab *); 4747c478bd9Sstevel@tonic-gate extern int zonecfg_endnwifent(zone_dochandle_t); 4757c478bd9Sstevel@tonic-gate extern int zonecfg_setdevent(zone_dochandle_t); 4767c478bd9Sstevel@tonic-gate extern int zonecfg_getdevent(zone_dochandle_t, struct zone_devtab *); 4777c478bd9Sstevel@tonic-gate extern int zonecfg_enddevent(zone_dochandle_t); 4787c478bd9Sstevel@tonic-gate extern int zonecfg_setattrent(zone_dochandle_t); 4797c478bd9Sstevel@tonic-gate extern int zonecfg_getattrent(zone_dochandle_t, struct zone_attrtab *); 4807c478bd9Sstevel@tonic-gate extern int zonecfg_endattrent(zone_dochandle_t); 4817c478bd9Sstevel@tonic-gate extern int zonecfg_setrctlent(zone_dochandle_t); 4827c478bd9Sstevel@tonic-gate extern int zonecfg_getrctlent(zone_dochandle_t, struct zone_rctltab *); 4837c478bd9Sstevel@tonic-gate extern int zonecfg_endrctlent(zone_dochandle_t); 484fa9e4066Sahrens extern int zonecfg_setdsent(zone_dochandle_t); 485fa9e4066Sahrens extern int zonecfg_getdsent(zone_dochandle_t, struct zone_dstab *); 486fa9e4066Sahrens extern int zonecfg_enddsent(zone_dochandle_t); 4870209230bSgjelinek extern int zonecfg_getpsetent(zone_dochandle_t, struct zone_psettab *); 4880209230bSgjelinek extern int zonecfg_getmcapent(zone_dochandle_t, struct zone_mcaptab *); 4896cfd72c6Sgjelinek extern int zonecfg_getpkgdata(zone_dochandle_t, uu_avl_pool_t *, 4906cfd72c6Sgjelinek uu_avl_t *); 491ee519a1fSgjelinek extern int zonecfg_setdevperment(zone_dochandle_t); 492ee519a1fSgjelinek extern int zonecfg_getdevperment(zone_dochandle_t, 493ee519a1fSgjelinek struct zone_devpermtab *); 494ee519a1fSgjelinek extern int zonecfg_enddevperment(zone_dochandle_t); 495cb8a054bSGlenn Faden extern int zonecfg_setadminent(zone_dochandle_t); 496cb8a054bSGlenn Faden extern int zonecfg_getadminent(zone_dochandle_t, struct zone_admintab *); 497cb8a054bSGlenn Faden extern int zonecfg_endadminent(zone_dochandle_t); 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate /* 5007c478bd9Sstevel@tonic-gate * Privilege-related functions. 5017c478bd9Sstevel@tonic-gate */ 502bf1d7e28Sdh155122 extern int zonecfg_default_privset(priv_set_t *, const char *); 503ffbafc53Scomay extern int zonecfg_get_privset(zone_dochandle_t, priv_set_t *, 504ffbafc53Scomay char **); 505ffbafc53Scomay extern int zonecfg_get_limitpriv(zone_dochandle_t, char **); 506ffbafc53Scomay extern int zonecfg_set_limitpriv(zone_dochandle_t, char *); 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate /* 5097c478bd9Sstevel@tonic-gate * Higher-level routines. 5107c478bd9Sstevel@tonic-gate */ 5119acbbeafSnn35248 extern int zone_get_brand(char *, char *, size_t); 5127c478bd9Sstevel@tonic-gate extern int zone_get_rootpath(char *, char *, size_t); 513facf4a8dSllai1 extern int zone_get_devroot(char *, char *, size_t); 5147c478bd9Sstevel@tonic-gate extern int zone_get_zonepath(char *, char *, size_t); 5157c478bd9Sstevel@tonic-gate extern int zone_get_state(char *, zone_state_t *); 5167c478bd9Sstevel@tonic-gate extern int zone_set_state(char *, zone_state_t); 5177c478bd9Sstevel@tonic-gate extern char *zone_state_str(zone_state_t); 518108322fbScarlsonj extern int zonecfg_get_name_by_uuid(const uuid_t, char *, size_t); 519108322fbScarlsonj extern int zonecfg_get_uuid(const char *, uuid_t); 520e5816e35SEdward Pilatowicz extern int zonecfg_default_brand(char *, size_t); 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate /* 5237c478bd9Sstevel@tonic-gate * Iterator for configured zones. 5247c478bd9Sstevel@tonic-gate */ 5257c478bd9Sstevel@tonic-gate extern FILE *setzoneent(void); 5267c478bd9Sstevel@tonic-gate extern char *getzoneent(FILE *); 5277c478bd9Sstevel@tonic-gate extern struct zoneent *getzoneent_private(FILE *); 5287c478bd9Sstevel@tonic-gate extern void endzoneent(FILE *); 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate /* 5317c478bd9Sstevel@tonic-gate * File-system-related convenience functions. 5327c478bd9Sstevel@tonic-gate */ 5337c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_valid_fs_type(const char *); 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate /* 5367c478bd9Sstevel@tonic-gate * Network-related convenience functions. 5377c478bd9Sstevel@tonic-gate */ 5387c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_same_net_address(char *, char *); 5397c478bd9Sstevel@tonic-gate extern int zonecfg_valid_net_address(char *, struct lifreq *); 540f4b3ec61Sdh155122 extern boolean_t zonecfg_ifname_exists(sa_family_t, char *); 5417c478bd9Sstevel@tonic-gate 5427c478bd9Sstevel@tonic-gate /* 5437c478bd9Sstevel@tonic-gate * Rctl-related common functions. 5447c478bd9Sstevel@tonic-gate */ 5457c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_is_rctl(const char *); 5467c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_valid_rctlname(const char *); 5477c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_valid_rctlblk(const rctlblk_t *); 5487c478bd9Sstevel@tonic-gate extern boolean_t zonecfg_valid_rctl(const char *, const rctlblk_t *); 5497c478bd9Sstevel@tonic-gate extern int zonecfg_construct_rctlblk(const struct zone_rctlvaltab *, 5507c478bd9Sstevel@tonic-gate rctlblk_t *); 5517c478bd9Sstevel@tonic-gate 552108322fbScarlsonj /* 553108322fbScarlsonj * Live Upgrade support functions. Shared between ON and install gate. 554108322fbScarlsonj */ 555108322fbScarlsonj extern FILE *zonecfg_open_scratch(const char *, boolean_t); 556108322fbScarlsonj extern int zonecfg_lock_scratch(FILE *); 557108322fbScarlsonj extern void zonecfg_close_scratch(FILE *); 558108322fbScarlsonj extern int zonecfg_get_scratch(FILE *, char *, size_t, char *, size_t, char *, 559108322fbScarlsonj size_t); 560108322fbScarlsonj extern int zonecfg_find_scratch(FILE *, const char *, const char *, char *, 561108322fbScarlsonj size_t); 562108322fbScarlsonj extern int zonecfg_reverse_scratch(FILE *, const char *, char *, size_t, 563108322fbScarlsonj char *, size_t); 564108322fbScarlsonj extern int zonecfg_add_scratch(FILE *, const char *, const char *, 565108322fbScarlsonj const char *); 566108322fbScarlsonj extern int zonecfg_delete_scratch(FILE *, const char *); 567108322fbScarlsonj extern boolean_t zonecfg_is_scratch(const char *); 568108322fbScarlsonj 569ff17c8bfSgjelinek /* 570ff17c8bfSgjelinek * zoneadmd support functions. Shared between zoneadm and brand hook code. 571ff17c8bfSgjelinek */ 572ff17c8bfSgjelinek extern void zonecfg_init_lock_file(const char *, char **); 573ff17c8bfSgjelinek extern void zonecfg_release_lock_file(const char *, int); 574ff17c8bfSgjelinek extern int zonecfg_grab_lock_file(const char *, int *); 575edfa49ffS extern boolean_t zonecfg_lock_file_held(int *); 576ff17c8bfSgjelinek extern int zonecfg_ping_zoneadmd(const char *); 577ff17c8bfSgjelinek extern int zonecfg_call_zoneadmd(const char *, zone_cmd_arg_t *, char *, 578ff17c8bfSgjelinek boolean_t); 579cb8a054bSGlenn Faden extern int zonecfg_insert_userauths(zone_dochandle_t, char *, char *); 580cb8a054bSGlenn Faden extern int zonecfg_remove_userauths(zone_dochandle_t, char *, char *, 581cb8a054bSGlenn Faden boolean_t); 582cb8a054bSGlenn Faden extern int zonecfg_add_admin(zone_dochandle_t, struct zone_admintab *, 583cb8a054bSGlenn Faden char *); 584cb8a054bSGlenn Faden extern int zonecfg_delete_admin(zone_dochandle_t, 585cb8a054bSGlenn Faden struct zone_admintab *, char *); 586cb8a054bSGlenn Faden extern int zonecfg_modify_admin(zone_dochandle_t, struct zone_admintab *, 587cb8a054bSGlenn Faden struct zone_admintab *, char *); 588cb8a054bSGlenn Faden extern int zonecfg_delete_admins(zone_dochandle_t, char *); 589cb8a054bSGlenn Faden extern int zonecfg_lookup_admin(zone_dochandle_t, struct zone_admintab *); 590cb8a054bSGlenn Faden extern int zonecfg_authorize_users(zone_dochandle_t, char *); 591cb8a054bSGlenn Faden extern int zonecfg_update_userauths(zone_dochandle_t, char *); 592cb8a054bSGlenn Faden extern int zonecfg_deauthorize_user(zone_dochandle_t, char *, char *); 593cb8a054bSGlenn Faden extern int zonecfg_deauthorize_users(zone_dochandle_t, char *); 594cb8a054bSGlenn Faden extern boolean_t zonecfg_valid_auths(const char *, const char *); 595ff17c8bfSgjelinek 5967c478bd9Sstevel@tonic-gate #ifdef __cplusplus 5977c478bd9Sstevel@tonic-gate } 5987c478bd9Sstevel@tonic-gate #endif 5997c478bd9Sstevel@tonic-gate 6007c478bd9Sstevel@tonic-gate #endif /* _LIBZONECFG_H */ 601