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