xref: /onnv-gate/usr/src/cmd/zoneadmd/zoneadmd.h (revision 13122:61fe7fb74c94)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51645Scomay  * Common Development and Distribution License (the "License").
61645Scomay  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211645Scomay 
220Sstevel@tonic-gate /*
23*13122SStephen.Lawrence@oracle.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_ZONEADMD_H
270Sstevel@tonic-gate #define	_ZONEADMD_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
338453SAnurag.Maskey@Sun.COM #include <libdladm.h>
348453SAnurag.Maskey@Sun.COM 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
370Sstevel@tonic-gate  * thing which could try to acquire a user-level lock unprotected by an atfork
380Sstevel@tonic-gate  * handler) between fork(2) and exec(2).  See the pthread_atfork(3THR) man
390Sstevel@tonic-gate  * page for details.  In particular, we want to avoid calls to zerror() in
400Sstevel@tonic-gate  * such situations, as it calls setlocale(3c) which is susceptible to such
410Sstevel@tonic-gate  * problems.  So instead we have the child use one of the special exit codes
420Sstevel@tonic-gate  * below when needed, and the parent look out for such possibilities and call
430Sstevel@tonic-gate  * zerror() there.
440Sstevel@tonic-gate  *
450Sstevel@tonic-gate  * Since 0, 1 and 2 are generally used for success, general error, and usage,
460Sstevel@tonic-gate  * we start with 3.
470Sstevel@tonic-gate  */
480Sstevel@tonic-gate #define	ZEXIT_FORK		3
490Sstevel@tonic-gate #define	ZEXIT_EXEC		4
500Sstevel@tonic-gate #define	ZEXIT_ZONE_ENTER	5
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #define	DEVFSADM	"devfsadm"
530Sstevel@tonic-gate #define	DEVFSADM_PATH	"/usr/sbin/devfsadm"
540Sstevel@tonic-gate 
552712Snn35248 #define	EXEC_PREFIX	"exec "
562712Snn35248 #define	EXEC_LEN	(strlen(EXEC_PREFIX))
572712Snn35248 
584350Std153743 #define	CLUSTER_BRAND_NAME	"cluster"
598905SRic.Aleshire@Sun.COM #define	LABELED_BRAND_NAME	"labeled"
604350Std153743 
615182Sedp /* 0755 is the default directory mode. */
625182Sedp #define	DEFAULT_DIR_MODE \
635182Sedp 	(S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
645182Sedp #define	DEFAULT_DIR_USER -1	/* user ID for chown: -1 means don't change */
655182Sedp #define	DEFAULT_DIR_GROUP -1	/* grp ID for chown: -1 means don't change */
665182Sedp 
675182Sedp 
680Sstevel@tonic-gate typedef struct zlog {
690Sstevel@tonic-gate 	FILE *logfile;	/* file to log to */
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	/*
720Sstevel@tonic-gate 	 * The following are used if logging to a buffer.
730Sstevel@tonic-gate 	 */
740Sstevel@tonic-gate 	char *log;	/* remaining log */
750Sstevel@tonic-gate 	size_t loglen;	/* size of remaining log */
760Sstevel@tonic-gate 	char *buf;	/* underlying storage */
770Sstevel@tonic-gate 	size_t buflen;	/* total len of 'buf' */
780Sstevel@tonic-gate 	char *locale;	/* locale to use for gettext() */
790Sstevel@tonic-gate } zlog_t;
800Sstevel@tonic-gate 
812611Svp157776 extern zlog_t logsys;
822611Svp157776 
830Sstevel@tonic-gate extern mutex_t lock;
840Sstevel@tonic-gate extern mutex_t msglock;
850Sstevel@tonic-gate extern boolean_t in_death_throes;
860Sstevel@tonic-gate extern boolean_t bringup_failure_recovery;
870Sstevel@tonic-gate extern char *zone_name;
88*13122SStephen.Lawrence@oracle.COM extern char pool_name[MAXNAMELEN];
8910796SStephen.Lawrence@Sun.COM extern char brand_name[MAXNAMELEN];
9010943SEdward.Pilatowicz@Sun.COM extern char default_brand[MAXNAMELEN];
912267Sdp extern char boot_args[BOOTARGS_MAX];
922267Sdp extern char bad_boot_arg[BOOTARGS_MAX];
932712Snn35248 extern boolean_t zone_isnative;
944350Std153743 extern boolean_t zone_iscluster;
958453SAnurag.Maskey@Sun.COM extern dladm_handle_t dld_handle;
960Sstevel@tonic-gate 
970Sstevel@tonic-gate extern void zerror(zlog_t *, boolean_t, const char *, ...);
980Sstevel@tonic-gate extern char *localize_msg(char *locale, const char *msg);
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * Eventstream interfaces.
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate typedef enum {
1040Sstevel@tonic-gate 	Z_EVT_NULL = 0,
1050Sstevel@tonic-gate 	Z_EVT_ZONE_BOOTING,
1060Sstevel@tonic-gate 	Z_EVT_ZONE_REBOOTING,
1070Sstevel@tonic-gate 	Z_EVT_ZONE_HALTED,
1080Sstevel@tonic-gate 	Z_EVT_ZONE_READIED,
1091645Scomay 	Z_EVT_ZONE_UNINSTALLING,
1102267Sdp 	Z_EVT_ZONE_BOOTFAILED,
1112267Sdp 	Z_EVT_ZONE_BADARGS
1120Sstevel@tonic-gate } zone_evt_t;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate extern int eventstream_init();
1150Sstevel@tonic-gate extern void eventstream_write(zone_evt_t evt);
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1185829Sgjelinek  * Zone mount styles.  Boot is the standard mount we do when booting the zone,
1195829Sgjelinek  * scratch is the standard scratch zone mount for upgrade and update is a
1205829Sgjelinek  * variation on the scratch zone where we don't lofs mount the zone's /etc
1215829Sgjelinek  * and /var back into the scratch zone so that we can then do an
1225829Sgjelinek  * 'update on attach' within the scratch zone.
1235829Sgjelinek  */
1245829Sgjelinek typedef enum {
1255829Sgjelinek 	Z_MNT_BOOT = 0,
1265829Sgjelinek 	Z_MNT_SCRATCH,
1275829Sgjelinek 	Z_MNT_UPDATE
1285829Sgjelinek } zone_mnt_t;
1295829Sgjelinek 
1305829Sgjelinek /*
1310Sstevel@tonic-gate  * Virtual platform interfaces.
1320Sstevel@tonic-gate  */
1335829Sgjelinek extern zoneid_t vplat_create(zlog_t *, zone_mnt_t);
1345829Sgjelinek extern int vplat_bringup(zlog_t *, zone_mnt_t, zoneid_t);
1353247Sgjelinek extern int vplat_teardown(zlog_t *, boolean_t, boolean_t);
13610616SSebastien.Roy@Sun.COM extern int vplat_get_iptype(zlog_t *, zone_iptype_t *);
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1395182Sedp  * Filesystem mounting interfaces.
1405182Sedp  */
1415182Sedp extern int valid_mount_path(zlog_t *, const char *, const char *,
1425182Sedp     const char *, const char *);
1435182Sedp extern int make_one_dir(zlog_t *, const char *, const char *,
1445182Sedp     mode_t, uid_t, gid_t);
1455576Sedp extern void resolve_lofs(zlog_t *zlogp, char *path, size_t pathlen);
1465182Sedp 
1475182Sedp /*
1480Sstevel@tonic-gate  * Console subsystem routines.
1490Sstevel@tonic-gate  */
1500Sstevel@tonic-gate extern int init_console(zlog_t *);
1510Sstevel@tonic-gate extern void serve_console(zlog_t *);
1520Sstevel@tonic-gate 
1532303Scarlsonj /*
1542303Scarlsonj  * Contract handling.
1552303Scarlsonj  */
1562303Scarlsonj extern int init_template(void);
1572303Scarlsonj 
1582712Snn35248 /*
1592712Snn35248  * Routine to manage child processes.
1602712Snn35248  */
1617370S<Gerald Jelinek> extern int do_subproc(zlog_t *, char *, char **);
1622712Snn35248 
1630Sstevel@tonic-gate #ifdef __cplusplus
1640Sstevel@tonic-gate }
1650Sstevel@tonic-gate #endif
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #endif /* _ZONEADMD_H */
168