xref: /titanic_50/usr/src/cmd/zoneadmd/zoneadmd.h (revision 41efec2219526a9b3ecce26f97aba761ef1e1d0d)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_ZONEADMD_H
28 #define	_ZONEADMD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
38  * thing which could try to acquire a user-level lock unprotected by an atfork
39  * handler) between fork(2) and exec(2).  See the pthread_atfork(3THR) man
40  * page for details.  In particular, we want to avoid calls to zerror() in
41  * such situations, as it calls setlocale(3c) which is susceptible to such
42  * problems.  So instead we have the child use one of the special exit codes
43  * below when needed, and the parent look out for such possibilities and call
44  * zerror() there.
45  *
46  * Since 0, 1 and 2 are generally used for success, general error, and usage,
47  * we start with 3.
48  */
49 #define	ZEXIT_FORK		3
50 #define	ZEXIT_EXEC		4
51 #define	ZEXIT_ZONE_ENTER	5
52 
53 #define	DEVFSADM	"devfsadm"
54 #define	DEVFSADM_PATH	"/usr/sbin/devfsadm"
55 
56 #define	EXEC_PREFIX	"exec "
57 #define	EXEC_LEN	(strlen(EXEC_PREFIX))
58 
59 #define	CLUSTER_BRAND_NAME	"cluster"
60 
61 typedef struct zlog {
62 	FILE *logfile;	/* file to log to */
63 
64 	/*
65 	 * The following are used if logging to a buffer.
66 	 */
67 	char *log;	/* remaining log */
68 	size_t loglen;	/* size of remaining log */
69 	char *buf;	/* underlying storage */
70 	size_t buflen;	/* total len of 'buf' */
71 	char *locale;	/* locale to use for gettext() */
72 } zlog_t;
73 
74 extern zlog_t logsys;
75 
76 extern mutex_t lock;
77 extern mutex_t msglock;
78 extern boolean_t in_death_throes;
79 extern boolean_t bringup_failure_recovery;
80 extern char *zone_name;
81 extern char boot_args[BOOTARGS_MAX];
82 extern char bad_boot_arg[BOOTARGS_MAX];
83 extern boolean_t zone_isnative;
84 extern boolean_t zone_iscluster;
85 
86 extern void zerror(zlog_t *, boolean_t, const char *, ...);
87 extern char *localize_msg(char *locale, const char *msg);
88 
89 /*
90  * Eventstream interfaces.
91  */
92 typedef enum {
93 	Z_EVT_NULL = 0,
94 	Z_EVT_ZONE_BOOTING,
95 	Z_EVT_ZONE_REBOOTING,
96 	Z_EVT_ZONE_HALTED,
97 	Z_EVT_ZONE_READIED,
98 	Z_EVT_ZONE_UNINSTALLING,
99 	Z_EVT_ZONE_BOOTFAILED,
100 	Z_EVT_ZONE_BADARGS
101 } zone_evt_t;
102 
103 extern int eventstream_init();
104 extern void eventstream_write(zone_evt_t evt);
105 
106 /*
107  * Virtual platform interfaces.
108  */
109 extern zoneid_t vplat_create(zlog_t *, boolean_t);
110 extern int vplat_bringup(zlog_t *, boolean_t, zoneid_t);
111 extern int vplat_teardown(zlog_t *, boolean_t, boolean_t);
112 
113 /*
114  * Console subsystem routines.
115  */
116 extern int init_console_slave(zlog_t *);
117 extern void destroy_console_slave(void);
118 extern void reset_slave_terminal(zlog_t *);
119 extern int init_console(zlog_t *);
120 extern void serve_console(zlog_t *);
121 
122 /*
123  * Contract handling.
124  */
125 extern int init_template(void);
126 
127 /*
128  * Routine to manage child processes.
129  */
130 extern int do_subproc(zlog_t *, char *);
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* _ZONEADMD_H */
137