xref: /titanic_53/usr/src/cmd/zoneadmd/zoneadmd.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_ZONEADMD_H
28*7c478bd9Sstevel@tonic-gate #define	_ZONEADMD_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate /*
37*7c478bd9Sstevel@tonic-gate  * Multi-threaded programs should avoid MT-unsafe library calls (i.e., any-
38*7c478bd9Sstevel@tonic-gate  * thing which could try to acquire a user-level lock unprotected by an atfork
39*7c478bd9Sstevel@tonic-gate  * handler) between fork(2) and exec(2).  See the pthread_atfork(3THR) man
40*7c478bd9Sstevel@tonic-gate  * page for details.  In particular, we want to avoid calls to zerror() in
41*7c478bd9Sstevel@tonic-gate  * such situations, as it calls setlocale(3c) which is susceptible to such
42*7c478bd9Sstevel@tonic-gate  * problems.  So instead we have the child use one of the special exit codes
43*7c478bd9Sstevel@tonic-gate  * below when needed, and the parent look out for such possibilities and call
44*7c478bd9Sstevel@tonic-gate  * zerror() there.
45*7c478bd9Sstevel@tonic-gate  *
46*7c478bd9Sstevel@tonic-gate  * Since 0, 1 and 2 are generally used for success, general error, and usage,
47*7c478bd9Sstevel@tonic-gate  * we start with 3.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate #define	ZEXIT_FORK		3
50*7c478bd9Sstevel@tonic-gate #define	ZEXIT_EXEC		4
51*7c478bd9Sstevel@tonic-gate #define	ZEXIT_ZONE_ENTER	5
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate #define	DEVFSADM	"devfsadm"
54*7c478bd9Sstevel@tonic-gate #define	DEVFSADM_PATH	"/usr/sbin/devfsadm"
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate typedef struct zlog {
57*7c478bd9Sstevel@tonic-gate 	FILE *logfile;	/* file to log to */
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 	/*
60*7c478bd9Sstevel@tonic-gate 	 * The following are used if logging to a buffer.
61*7c478bd9Sstevel@tonic-gate 	 */
62*7c478bd9Sstevel@tonic-gate 	char *log;	/* remaining log */
63*7c478bd9Sstevel@tonic-gate 	size_t loglen;	/* size of remaining log */
64*7c478bd9Sstevel@tonic-gate 	char *buf;	/* underlying storage */
65*7c478bd9Sstevel@tonic-gate 	size_t buflen;	/* total len of 'buf' */
66*7c478bd9Sstevel@tonic-gate 	char *locale;	/* locale to use for gettext() */
67*7c478bd9Sstevel@tonic-gate } zlog_t;
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate extern mutex_t lock;
70*7c478bd9Sstevel@tonic-gate extern mutex_t msglock;
71*7c478bd9Sstevel@tonic-gate extern boolean_t in_death_throes;
72*7c478bd9Sstevel@tonic-gate extern boolean_t bringup_failure_recovery;
73*7c478bd9Sstevel@tonic-gate extern char *zone_name;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate extern void zerror(zlog_t *, boolean_t, const char *, ...);
76*7c478bd9Sstevel@tonic-gate extern char *localize_msg(char *locale, const char *msg);
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /*
79*7c478bd9Sstevel@tonic-gate  * Eventstream interfaces.
80*7c478bd9Sstevel@tonic-gate  */
81*7c478bd9Sstevel@tonic-gate typedef enum {
82*7c478bd9Sstevel@tonic-gate 	Z_EVT_NULL = 0,
83*7c478bd9Sstevel@tonic-gate 	Z_EVT_ZONE_BOOTING,
84*7c478bd9Sstevel@tonic-gate 	Z_EVT_ZONE_REBOOTING,
85*7c478bd9Sstevel@tonic-gate 	Z_EVT_ZONE_HALTED,
86*7c478bd9Sstevel@tonic-gate 	Z_EVT_ZONE_READIED,
87*7c478bd9Sstevel@tonic-gate 	Z_EVT_ZONE_UNINSTALLING
88*7c478bd9Sstevel@tonic-gate } zone_evt_t;
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate extern int eventstream_init();
91*7c478bd9Sstevel@tonic-gate extern void eventstream_write(zone_evt_t evt);
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  * Virtual platform interfaces.
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate extern int vplat_create(zlog_t *);
97*7c478bd9Sstevel@tonic-gate extern int vplat_bringup(zlog_t *);
98*7c478bd9Sstevel@tonic-gate extern int vplat_teardown(zlog_t *);
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /*
102*7c478bd9Sstevel@tonic-gate  * Console subsystem routines.
103*7c478bd9Sstevel@tonic-gate  */
104*7c478bd9Sstevel@tonic-gate extern int init_console_slave(zlog_t *);
105*7c478bd9Sstevel@tonic-gate extern void destroy_console_slave(void);
106*7c478bd9Sstevel@tonic-gate extern void reset_slave_terminal(zlog_t *);
107*7c478bd9Sstevel@tonic-gate extern int init_console(zlog_t *);
108*7c478bd9Sstevel@tonic-gate extern void serve_console(zlog_t *);
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
111*7c478bd9Sstevel@tonic-gate }
112*7c478bd9Sstevel@tonic-gate #endif
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #endif /* _ZONEADMD_H */
115