xref: /illumos-gate/usr/src/cmd/zoneadmd/zoneadmd.h (revision 65a89a64c60f3061bbe2381edaacc81660af9a95)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 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 typedef struct zlog {
57 	FILE *logfile;	/* file to log to */
58 
59 	/*
60 	 * The following are used if logging to a buffer.
61 	 */
62 	char *log;	/* remaining log */
63 	size_t loglen;	/* size of remaining log */
64 	char *buf;	/* underlying storage */
65 	size_t buflen;	/* total len of 'buf' */
66 	char *locale;	/* locale to use for gettext() */
67 } zlog_t;
68 
69 extern mutex_t lock;
70 extern mutex_t msglock;
71 extern boolean_t in_death_throes;
72 extern boolean_t bringup_failure_recovery;
73 extern char *zone_name;
74 
75 extern void zerror(zlog_t *, boolean_t, const char *, ...);
76 extern char *localize_msg(char *locale, const char *msg);
77 
78 /*
79  * Eventstream interfaces.
80  */
81 typedef enum {
82 	Z_EVT_NULL = 0,
83 	Z_EVT_ZONE_BOOTING,
84 	Z_EVT_ZONE_REBOOTING,
85 	Z_EVT_ZONE_HALTED,
86 	Z_EVT_ZONE_READIED,
87 	Z_EVT_ZONE_UNINSTALLING
88 } zone_evt_t;
89 
90 extern int eventstream_init();
91 extern void eventstream_write(zone_evt_t evt);
92 
93 /*
94  * Virtual platform interfaces.
95  */
96 extern zoneid_t vplat_create(zlog_t *, boolean_t);
97 extern int vplat_bringup(zlog_t *, boolean_t);
98 extern int vplat_teardown(zlog_t *, boolean_t);
99 
100 
101 /*
102  * Console subsystem routines.
103  */
104 extern int init_console_slave(zlog_t *);
105 extern void destroy_console_slave(void);
106 extern void reset_slave_terminal(zlog_t *);
107 extern int init_console(zlog_t *);
108 extern void serve_console(zlog_t *);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* _ZONEADMD_H */
115