xref: /onnv-gate/usr/src/cmd/svc/startd/startd.h (revision 5680:0c36d39ff12f)
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
51712Srm88369  * Common Development and Distribution License (the "License").
61712Srm88369  * 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  */
210Sstevel@tonic-gate /*
224244Sjeanm  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_STARTD_H
270Sstevel@tonic-gate #define	_STARTD_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/time.h>
320Sstevel@tonic-gate #include <librestart.h>
330Sstevel@tonic-gate #include <librestart_priv.h>
340Sstevel@tonic-gate #include <libscf.h>
350Sstevel@tonic-gate #include <libsysevent.h>
360Sstevel@tonic-gate #include <libuutil.h>
370Sstevel@tonic-gate #include <pthread.h>
380Sstevel@tonic-gate #include <stdio.h>
390Sstevel@tonic-gate #include <syslog.h>
400Sstevel@tonic-gate #include <umem.h>
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	__cplusplus
430Sstevel@tonic-gate extern "C" {
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * We want MUTEX_HELD, but we also want pthreads.  So we're stuck with this.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate #define	PTHREAD_MUTEX_HELD(m)	_mutex_held((struct _lwp_mutex *)(m))
500Sstevel@tonic-gate 
510Sstevel@tonic-gate #ifndef NDEBUG
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #define	MUTEX_LOCK(mp)	{						\
540Sstevel@tonic-gate 	int err;							\
550Sstevel@tonic-gate 	if ((err = pthread_mutex_lock((mp))) != 0) {			\
560Sstevel@tonic-gate 		(void) fprintf(stderr,					\
570Sstevel@tonic-gate 		    "pthread_mutex_lock() failed on %s:%d: %s\n",	\
580Sstevel@tonic-gate 		    __FILE__, __LINE__, strerror(err));			\
590Sstevel@tonic-gate 		abort();						\
600Sstevel@tonic-gate 	}								\
610Sstevel@tonic-gate }
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	MUTEX_UNLOCK(mp)	{					\
640Sstevel@tonic-gate 	int err;							\
650Sstevel@tonic-gate 	if ((err = pthread_mutex_unlock((mp))) != 0) {			\
660Sstevel@tonic-gate 		(void) fprintf(stderr,					\
670Sstevel@tonic-gate 		    "pthread_mutex_unlock() failed on %s:%d: %s\n",	\
680Sstevel@tonic-gate 		    __FILE__, __LINE__, strerror(err));			\
690Sstevel@tonic-gate 		abort();						\
700Sstevel@tonic-gate 	}								\
710Sstevel@tonic-gate }
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #else
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #define	MUTEX_LOCK(mp)		(void) pthread_mutex_lock((mp))
760Sstevel@tonic-gate #define	MUTEX_UNLOCK(mp)	(void) pthread_mutex_unlock((mp))
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #endif
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #ifndef NDEBUG
810Sstevel@tonic-gate #define	bad_error(func, err)	{					\
820Sstevel@tonic-gate 	(void) fprintf(stderr, "%s:%d: %s() failed with unexpected "	\
830Sstevel@tonic-gate 	    "error %d.  Aborting.\n", __FILE__, __LINE__, (func), (err)); \
840Sstevel@tonic-gate 	abort();							\
850Sstevel@tonic-gate }
860Sstevel@tonic-gate #else
870Sstevel@tonic-gate #define	bad_error(func, err)	abort()
880Sstevel@tonic-gate #endif
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #define	min(a, b)	(((a) < (b)) ? (a) : (b))
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #define	FAULT_COUNT_INCR	0
940Sstevel@tonic-gate #define	FAULT_COUNT_RESET	1
950Sstevel@tonic-gate 
960Sstevel@tonic-gate #define	FAULT_THRESHOLD		3
970Sstevel@tonic-gate 
980Sstevel@tonic-gate #define	MAX_CONFIGD_RETRIES	5
990Sstevel@tonic-gate #define	MAX_MOUNT_RETRIES	5
1000Sstevel@tonic-gate #define	MAX_SULOGIN_RETRIES	5
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate #define	RETURN_SUCCESS		0
1030Sstevel@tonic-gate #define	RETURN_RETRY		-1
1040Sstevel@tonic-gate #define	RETURN_FATAL		-2
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate #define	LIBSCF_SUCCESS		0
1070Sstevel@tonic-gate #define	LIBSCF_PROPERTY_ABSENT	-1
1080Sstevel@tonic-gate #define	LIBSCF_PGROUP_ABSENT	-2
1090Sstevel@tonic-gate #define	LIBSCF_PROPERTY_ERROR	-3
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate #define	METHOD_START		0
1120Sstevel@tonic-gate #define	METHOD_STOP		1
1130Sstevel@tonic-gate #define	METHOD_REFRESH		2
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #define	METHOD_TIMEOUT_INFINITE	0
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1180Sstevel@tonic-gate  * Contract cookies used by startd.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate #define	CONFIGD_COOKIE		0x10
1210Sstevel@tonic-gate #define	SULOGIN_COOKIE		0x11
1220Sstevel@tonic-gate #define	METHOD_START_COOKIE	0x20
1230Sstevel@tonic-gate #define	METHOD_OTHER_COOKIE	0x21
1240Sstevel@tonic-gate #define	MONITOR_COOKIE		0x30
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate #define	ALLOC_RETRY		3
1280Sstevel@tonic-gate #define	ALLOC_DELAY		10
1290Sstevel@tonic-gate #define	ALLOC_DELAY_MULT	10
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate #define	safe_scf_scope_create(h)	\
1320Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_scope_create, (h))
1330Sstevel@tonic-gate #define	safe_scf_service_create(h)	\
1340Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_service_create, (h))
1350Sstevel@tonic-gate #define	safe_scf_instance_create(h)	libscf_object_create(	\
1360Sstevel@tonic-gate 	(void *(*)(scf_handle_t *))scf_instance_create, (h))
1370Sstevel@tonic-gate #define	safe_scf_snapshot_create(h)	libscf_object_create(	\
1380Sstevel@tonic-gate 	(void *(*)(scf_handle_t *))scf_snapshot_create, (h))
1390Sstevel@tonic-gate #define	safe_scf_snaplevel_create(h)	libscf_object_create(	\
1400Sstevel@tonic-gate 	(void *(*)(scf_handle_t *))scf_snaplevel_create, (h))
1410Sstevel@tonic-gate #define	safe_scf_pg_create(h)		\
1420Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_pg_create, (h))
1430Sstevel@tonic-gate #define	safe_scf_property_create(h)	libscf_object_create(	\
1440Sstevel@tonic-gate 	(void *(*)(scf_handle_t *))scf_property_create, (h))
1450Sstevel@tonic-gate #define	safe_scf_value_create(h)	\
1460Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_value_create, (h))
1470Sstevel@tonic-gate #define	safe_scf_iter_create(h)		\
1480Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_iter_create, (h))
1490Sstevel@tonic-gate #define	safe_scf_transaction_create(h)	libscf_object_create(	\
1500Sstevel@tonic-gate 	(void *(*)(scf_handle_t *))	scf_transaction_create, (h))
1510Sstevel@tonic-gate #define	safe_scf_entry_create(h)	\
1520Sstevel@tonic-gate 	libscf_object_create((void *(*)(scf_handle_t *))scf_entry_create, (h))
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate #define	startd_alloc(sz)	\
1550Sstevel@tonic-gate 	startd_alloc_retry((void *(*)(size_t, int))umem_alloc, (sz))
1560Sstevel@tonic-gate #define	startd_zalloc(sz)	\
1570Sstevel@tonic-gate 	startd_alloc_retry((void *(*)(size_t, int))umem_zalloc, (sz))
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate extern pthread_mutexattr_t mutex_attrs;
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate /*
1630Sstevel@tonic-gate  * Definitions for administrative actions.
1640Sstevel@tonic-gate  *   Note that the ordering in admin_action_t, admin_actions, and admin_events
1650Sstevel@tonic-gate  *   must match.  admin_actions and admin_events are defined in startd.c.
1660Sstevel@tonic-gate  */
1670Sstevel@tonic-gate #define	NACTIONS			6
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate typedef enum {
1700Sstevel@tonic-gate 	ADMIN_EVENT_DEGRADED = 0x0,
1710Sstevel@tonic-gate 	ADMIN_EVENT_MAINT_OFF,
1720Sstevel@tonic-gate 	ADMIN_EVENT_MAINT_ON,
1730Sstevel@tonic-gate 	ADMIN_EVENT_MAINT_ON_IMMEDIATE,
1740Sstevel@tonic-gate 	ADMIN_EVENT_REFRESH,
1750Sstevel@tonic-gate 	ADMIN_EVENT_RESTART
1760Sstevel@tonic-gate } admin_action_t;
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate extern const char * const admin_actions[NACTIONS];
1790Sstevel@tonic-gate extern const int admin_events[NACTIONS];
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate #define	LOG_DATE_SIZE	32	/* Max size of timestamp in log output */
1820Sstevel@tonic-gate 
1830Sstevel@tonic-gate extern ssize_t max_scf_name_size;
1840Sstevel@tonic-gate extern ssize_t max_scf_value_size;
1850Sstevel@tonic-gate extern ssize_t max_scf_fmri_size;
1860Sstevel@tonic-gate 
1870Sstevel@tonic-gate extern mode_t fmask;
1880Sstevel@tonic-gate extern mode_t dmask;
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate #define	LOG_PREFIX_EARLY	"/etc/svc/volatile/"
1910Sstevel@tonic-gate #define	LOG_PREFIX_NORMAL	"/var/svc/log/"
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate #define	LOG_SUFFIX		".log"
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate #define	STARTD_DEFAULT_LOG	"svc.startd.log"
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate extern const char *log_directory;	/* Current log directory path */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate #define	FS_TIMEZONE_DIR		"/usr/share/lib/zoneinfo"
2000Sstevel@tonic-gate #define	FS_LOCALE_DIR		"/usr/lib/locale"
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate /*
2030Sstevel@tonic-gate  * Simple dictionary representation.
2040Sstevel@tonic-gate  */
2050Sstevel@tonic-gate typedef struct dictionary {
2060Sstevel@tonic-gate 	uu_list_t		*dict_list;
2070Sstevel@tonic-gate 	int			dict_new_id;
2080Sstevel@tonic-gate 	pthread_mutex_t		dict_lock;
2090Sstevel@tonic-gate } dictionary_t;
2100Sstevel@tonic-gate 
2110Sstevel@tonic-gate typedef struct dict_entry {
2120Sstevel@tonic-gate 	int			de_id;
2130Sstevel@tonic-gate 	const char		*de_name;
2140Sstevel@tonic-gate 	uu_list_node_t		de_link;
2150Sstevel@tonic-gate } dict_entry_t;
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate extern dictionary_t *dictionary;
2180Sstevel@tonic-gate 
2190Sstevel@tonic-gate typedef struct timeout_queue {
2200Sstevel@tonic-gate 	uu_list_t		*tq_list;
2210Sstevel@tonic-gate 	pthread_mutex_t		tq_lock;
2220Sstevel@tonic-gate } timeout_queue_t;
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate typedef struct timeout_entry {
2250Sstevel@tonic-gate 	hrtime_t		te_timeout;	/* timeout expiration time */
2260Sstevel@tonic-gate 	ctid_t			te_ctid;
2270Sstevel@tonic-gate 	char			*te_fmri;
2280Sstevel@tonic-gate 	char			*te_logstem;
2290Sstevel@tonic-gate 	volatile int		te_fired;
2300Sstevel@tonic-gate 	uu_list_node_t		te_link;
2310Sstevel@tonic-gate } timeout_entry_t;
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate extern timeout_queue_t *timeouts;
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate /*
2360Sstevel@tonic-gate  * State definitions.
2370Sstevel@tonic-gate  */
2380Sstevel@tonic-gate typedef enum {
2390Sstevel@tonic-gate 	STATE_NONE = 0x0,
2400Sstevel@tonic-gate 	STATE_UNINIT,
2410Sstevel@tonic-gate 	STATE_MAINT,
2420Sstevel@tonic-gate 	STATE_OFFLINE,
2430Sstevel@tonic-gate 	STATE_DISABLED,
2440Sstevel@tonic-gate 	STATE_ONLINE,
2450Sstevel@tonic-gate 	STATE_DEGRADED
2460Sstevel@tonic-gate } instance_state_t;
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate #define	STATE_MAX	(STATE_DEGRADED + 1)
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate extern const char * const instance_state_str[STATE_MAX];
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate typedef enum {
2530Sstevel@tonic-gate 	GVT_UNSUPPORTED = -1,
2540Sstevel@tonic-gate 	GVT_UNKNOWN = 0,
2550Sstevel@tonic-gate 	GVT_SVC,		/* service */
2560Sstevel@tonic-gate 	GVT_INST,		/* instance */
2570Sstevel@tonic-gate 	GVT_FILE,		/* file: */
2580Sstevel@tonic-gate 	GVT_GROUP		/* dependency group */
2590Sstevel@tonic-gate } gv_type_t;
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate typedef enum {
2620Sstevel@tonic-gate 	DEPGRP_UNSUPPORTED = -1,
2630Sstevel@tonic-gate 	DEPGRP_REQUIRE_ANY = 1,
2640Sstevel@tonic-gate 	DEPGRP_REQUIRE_ALL,
2650Sstevel@tonic-gate 	DEPGRP_EXCLUDE_ALL,
2660Sstevel@tonic-gate 	DEPGRP_OPTIONAL_ALL
2670Sstevel@tonic-gate } depgroup_type_t;
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate typedef enum {
2700Sstevel@tonic-gate 	METHOD_RESTART_UNKNOWN = -1,
2710Sstevel@tonic-gate 	METHOD_RESTART_ALL = 0,
2720Sstevel@tonic-gate 	METHOD_RESTART_EXTERNAL_FAULT,
2730Sstevel@tonic-gate 	METHOD_RESTART_ANY_FAULT,
2740Sstevel@tonic-gate 	METHOD_RESTART_OTHER
2750Sstevel@tonic-gate } method_restart_t;
2760Sstevel@tonic-gate 
2772339Slianep typedef enum {
2782339Slianep 	PROPAGATE_START,
2792339Slianep 	PROPAGATE_STOP,
2802339Slianep 	PROPAGATE_SAT
2812339Slianep } propagate_event_t;
2822339Slianep 
2830Sstevel@tonic-gate /*
2840Sstevel@tonic-gate  * Graph representation.
2850Sstevel@tonic-gate  */
2860Sstevel@tonic-gate #define	GV_CONFIGURED	0x01	/* Service exists in repository, ready */
2870Sstevel@tonic-gate #define	GV_ENABLED	0x02	/* Service should be online */
2880Sstevel@tonic-gate #define	GV_ENBLD_NOOVR	0x04	/* GV_ENABLED, ignoring override */
2890Sstevel@tonic-gate #define	GV_INSUBGRAPH	0x08	/* Current milestone depends on service */
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate /* ID must come first to support search */
2920Sstevel@tonic-gate typedef struct graph_vertex {
2930Sstevel@tonic-gate 	int				gv_id;
2940Sstevel@tonic-gate 	char				*gv_name;
2950Sstevel@tonic-gate 	uu_list_node_t			gv_link;
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate 	uint_t				gv_flags;
2980Sstevel@tonic-gate 	restarter_instance_state_t	gv_state;
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate 	gv_type_t			gv_type;
3010Sstevel@tonic-gate 
3020Sstevel@tonic-gate 	depgroup_type_t			gv_depgroup;
3030Sstevel@tonic-gate 	restarter_error_t		gv_restart;
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate 	void				(*gv_start_f)(struct graph_vertex *);
3060Sstevel@tonic-gate 	void				(*gv_post_online_f)(void);
3070Sstevel@tonic-gate 	void				(*gv_post_disable_f)(void);
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate 	int				gv_restarter_id;
3100Sstevel@tonic-gate 	evchan_t			*gv_restarter_channel;
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate 	int				gv_delegate_initialized;
3130Sstevel@tonic-gate 	evchan_t			*gv_delegate_channel;
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate 	uu_list_t			*gv_dependencies;
3160Sstevel@tonic-gate 	uu_list_t			*gv_dependents;
3171712Srm88369 
3181712Srm88369 	/*
3191712Srm88369 	 * gv_refs represents the number of references besides dependencies.
3201712Srm88369 	 * The vertex cannot be removed when gv_refs > 0.
3211712Srm88369 	 *
3221712Srm88369 	 * Currently, only relevant for GVT_SVC and GVT_INST type vertices.
3231712Srm88369 	 */
3241712Srm88369 	int 				gv_refs;
3250Sstevel@tonic-gate } graph_vertex_t;
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate typedef struct graph_edge {
3280Sstevel@tonic-gate 	graph_vertex_t	*ge_vertex;
3290Sstevel@tonic-gate 	uu_list_node_t	ge_link;
3300Sstevel@tonic-gate 	graph_vertex_t	*ge_parent;
3310Sstevel@tonic-gate } graph_edge_t;
3320Sstevel@tonic-gate 
3330Sstevel@tonic-gate /*
3341958Slianep  * Restarter transition outcomes
3350Sstevel@tonic-gate  */
3360Sstevel@tonic-gate typedef enum {
3371958Slianep 	MAINT_REQUESTED,
3380Sstevel@tonic-gate 	START_REQUESTED,
3390Sstevel@tonic-gate 	START_FAILED_REPEATEDLY,
3400Sstevel@tonic-gate 	START_FAILED_CONFIGURATION,
3410Sstevel@tonic-gate 	START_FAILED_FATAL,
3420Sstevel@tonic-gate 	START_FAILED_TIMEOUT_FATAL,
3430Sstevel@tonic-gate 	START_FAILED_OTHER
3440Sstevel@tonic-gate } start_outcome_t;
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate typedef void (*instance_hook_t)(void);
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate typedef struct service_hook_assn {
3490Sstevel@tonic-gate 	char	*sh_fmri;
3500Sstevel@tonic-gate 	instance_hook_t	sh_pre_online_hook;
3510Sstevel@tonic-gate 	instance_hook_t	sh_post_online_hook;
3520Sstevel@tonic-gate 	instance_hook_t	sh_post_offline_hook;
3530Sstevel@tonic-gate } service_hook_assn_t;
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate /*
3560Sstevel@tonic-gate  * Restarter instance stop reasons.
3570Sstevel@tonic-gate  */
3580Sstevel@tonic-gate typedef enum {
3590Sstevel@tonic-gate 	RSTOP_EXIT = 0x0,	/* exited or empty */
3600Sstevel@tonic-gate 	RSTOP_CORE,		/* core dumped */
3610Sstevel@tonic-gate 	RSTOP_SIGNAL,		/* external fatal signal received */
3620Sstevel@tonic-gate 	RSTOP_HWERR,		/* uncorrectable hardware error */
3630Sstevel@tonic-gate 	RSTOP_DEPENDENCY,	/* dependency activity caused stop */
3640Sstevel@tonic-gate 	RSTOP_DISABLE,		/* disabled */
3650Sstevel@tonic-gate 	RSTOP_RESTART		/* restart requested */
3660Sstevel@tonic-gate } stop_cause_t;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate /*
3690Sstevel@tonic-gate  * Restarter instance maintenance clear reasons.
3700Sstevel@tonic-gate  */
3710Sstevel@tonic-gate typedef enum {
3720Sstevel@tonic-gate 	RUNMAINT_CLEAR = 0x0,
3730Sstevel@tonic-gate 	RUNMAINT_DISABLE
3740Sstevel@tonic-gate } unmaint_cause_t;
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate /*
3770Sstevel@tonic-gate  * Restarter instance flags
3780Sstevel@tonic-gate  */
3790Sstevel@tonic-gate #define	RINST_CONTRACT		0x00000000	/* progeny constitute inst */
3800Sstevel@tonic-gate #define	RINST_TRANSIENT		0x10000000	/* inst operates momentarily */
3810Sstevel@tonic-gate #define	RINST_WAIT		0x20000000	/* child constitutes inst */
3820Sstevel@tonic-gate #define	RINST_STYLE_MASK	0xf0000000
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #define	RINST_RETAKE_RUNNING	0x01000000	/* pending running snapshot */
3850Sstevel@tonic-gate #define	RINST_RETAKE_START	0x02000000	/* pending start snapshot */
3860Sstevel@tonic-gate 
3870Sstevel@tonic-gate #define	RINST_RETAKE_MASK	0x0f000000
3880Sstevel@tonic-gate 
3890Sstevel@tonic-gate #define	RINST_START_TIMES	10		/* failures to consider */
3900Sstevel@tonic-gate #define	RINST_FAILURE_RATE_NS	1000000000LL	/* 1 failure/second */
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /* Number of events in the queue when we start dropping ADMIN events. */
3930Sstevel@tonic-gate #define	RINST_QUEUE_THRESHOLD	100
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate typedef struct restarter_inst {
3960Sstevel@tonic-gate 	int			ri_id;
3970Sstevel@tonic-gate 	instance_data_t		ri_i;
3980Sstevel@tonic-gate 	char			*ri_common_name; /* template localized name */
3990Sstevel@tonic-gate 	char			*ri_C_common_name; /* C locale name */
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate 	char			*ri_logstem;	/* logfile name */
4020Sstevel@tonic-gate 	char			*ri_utmpx_prefix;
4030Sstevel@tonic-gate 	uint_t			ri_flags;
4040Sstevel@tonic-gate 	instance_hook_t		ri_pre_online_hook;
4050Sstevel@tonic-gate 	instance_hook_t		ri_post_online_hook;
4060Sstevel@tonic-gate 	instance_hook_t		ri_post_offline_hook;
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate 	hrtime_t		ri_start_time[RINST_START_TIMES];
4090Sstevel@tonic-gate 	uint_t			ri_start_index;	/* times started */
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate 	uu_list_node_t		ri_link;
4120Sstevel@tonic-gate 	pthread_mutex_t		ri_lock;
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate 	/*
4150Sstevel@tonic-gate 	 * When we start a thread to we execute a method for this instance, we
4160Sstevel@tonic-gate 	 * put the thread id in ri_method_thread.  Threads with ids other than
4170Sstevel@tonic-gate 	 * this which acquire ri_lock while ri_method_thread is nonzero should
4180Sstevel@tonic-gate 	 * wait on ri_method_cv.  ri_method_waiters should be incremented while
4190Sstevel@tonic-gate 	 * waiting so the instance won't be deleted.
4200Sstevel@tonic-gate 	 */
4210Sstevel@tonic-gate 	pthread_t		ri_method_thread;
4220Sstevel@tonic-gate 	pthread_cond_t		ri_method_cv;
4230Sstevel@tonic-gate 	uint_t			ri_method_waiters;
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate 	/*
4260Sstevel@tonic-gate 	 * These fields are provided so functions can operate on this structure
4270Sstevel@tonic-gate 	 * and the repository without worrying about whether the instance has
4280Sstevel@tonic-gate 	 * been deleted from the repository (this is possible because
4290Sstevel@tonic-gate 	 * ri_i.i_fmri names the instance this structure represents -- see
4300Sstevel@tonic-gate 	 * libscf_reget_inst()).  ri_m_inst is the scf_instance_t for the
4310Sstevel@tonic-gate 	 * instance, and ri_mi_deleted is true if the instance has been deleted.
4320Sstevel@tonic-gate 	 */
4330Sstevel@tonic-gate 	scf_instance_t		*ri_m_inst;
4340Sstevel@tonic-gate 	boolean_t		ri_mi_deleted;
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate 	/*
4370Sstevel@tonic-gate 	 * We maintain a pointer to any pending timeout for this instance
4380Sstevel@tonic-gate 	 * for quick reference/deletion.
4390Sstevel@tonic-gate 	 */
4400Sstevel@tonic-gate 	timeout_entry_t		*ri_timeout;
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate 	/*
4430Sstevel@tonic-gate 	 * Instance event queue.  Graph events are queued here as a list
4440Sstevel@tonic-gate 	 * of restarter_instance_qentry_t's, and the lock is held separately.
4450Sstevel@tonic-gate 	 * If both ri_lock and ri_queue_lock are grabbed, ri_lock must be
4460Sstevel@tonic-gate 	 * grabbed first.  ri_queue_lock protects all ri_queue_* structure
4470Sstevel@tonic-gate 	 * members.
4480Sstevel@tonic-gate 	 */
4490Sstevel@tonic-gate 	pthread_mutex_t		ri_queue_lock;
4500Sstevel@tonic-gate 	pthread_cond_t		ri_queue_cv;
4510Sstevel@tonic-gate 	uu_list_t		*ri_queue;
4520Sstevel@tonic-gate 	int			ri_queue_thread;
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate } restarter_inst_t;
4550Sstevel@tonic-gate 
4560Sstevel@tonic-gate typedef struct restarter_instance_list {
4570Sstevel@tonic-gate 	uu_list_t		*ril_instance_list;
4580Sstevel@tonic-gate 	pthread_mutex_t		ril_lock;
4590Sstevel@tonic-gate } restarter_instance_list_t;
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate typedef struct restarter_instance_qentry {
4620Sstevel@tonic-gate 	restarter_event_type_t	riq_type;
4630Sstevel@tonic-gate 	uu_list_node_t		riq_link;
4640Sstevel@tonic-gate } restarter_instance_qentry_t;
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate typedef struct fork_info {
4670Sstevel@tonic-gate 	int			sf_id;
4680Sstevel@tonic-gate 	int			sf_method_type;
4690Sstevel@tonic-gate 	restarter_error_t	sf_event_type;
4700Sstevel@tonic-gate } fork_info_t;
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate typedef struct wait_info {
4730Sstevel@tonic-gate 	uu_list_node_t		wi_link;
4740Sstevel@tonic-gate 
4750Sstevel@tonic-gate 	int			wi_fd;		/* psinfo file descriptor */
4760Sstevel@tonic-gate 	id_t			wi_pid;		/* process ID */
4770Sstevel@tonic-gate 	const char		*wi_fmri;	/* instance FMRI */
4780Sstevel@tonic-gate 	int			wi_parent;	/* startd is parent */
4790Sstevel@tonic-gate } wait_info_t;
4800Sstevel@tonic-gate 
4810Sstevel@tonic-gate #define	STARTD_LOG_FILE		0x1
4820Sstevel@tonic-gate #define	STARTD_LOG_TERMINAL	0x2
4830Sstevel@tonic-gate #define	STARTD_LOG_SYSLOG	0x4
4840Sstevel@tonic-gate 
4850Sstevel@tonic-gate #define	STARTD_BOOT_QUIET	0x1
4860Sstevel@tonic-gate #define	STARTD_BOOT_VERBOSE	0x2
4870Sstevel@tonic-gate 
488*5680Srm88369 /*
489*5680Srm88369  * Internal debug flags used to reduce the amount of data sent to the
490*5680Srm88369  * internal debug buffer. They can be turned on & off dynamically using
491*5680Srm88369  * internal_debug_flags variable in mdb. By default, they're off.
492*5680Srm88369  */
493*5680Srm88369 #define	DEBUG_DEPENDENCIES	0x1
494*5680Srm88369 
4950Sstevel@tonic-gate typedef struct startd_state {
4960Sstevel@tonic-gate 	/* Logging configuration */
4970Sstevel@tonic-gate 	char		*st_log_prefix;	/* directory prefix */
4980Sstevel@tonic-gate 	char		*st_log_file;	/* startd file in above dir */
4990Sstevel@tonic-gate 	uint_t		st_log_flags;	/* message destination */
5000Sstevel@tonic-gate 	int		st_log_level_min; /* minimum required to log */
5010Sstevel@tonic-gate 	int		st_log_timezone_known; /* timezone is available */
5020Sstevel@tonic-gate 	int		st_log_locale_known; /* locale is available */
5030Sstevel@tonic-gate 	int		st_log_login_reached; /* login service reached */
5040Sstevel@tonic-gate 
5050Sstevel@tonic-gate 	/* Boot configuration */
5060Sstevel@tonic-gate 	uint_t		st_boot_flags;	/* serial boot, etc. */
5070Sstevel@tonic-gate 	uint_t		st_initial;	/* first startd on system */
5080Sstevel@tonic-gate 
5090Sstevel@tonic-gate 	/* System configuration */
5100Sstevel@tonic-gate 	char		*st_subgraph;	/* milestone subgraph request */
5110Sstevel@tonic-gate 
5120Sstevel@tonic-gate 	uint_t		st_load_complete;  /* graph load completed */
5130Sstevel@tonic-gate 	uint_t		st_load_instances; /* restarter instances to load */
5140Sstevel@tonic-gate 	pthread_mutex_t	st_load_lock;
5150Sstevel@tonic-gate 	pthread_cond_t	st_load_cv;
5160Sstevel@tonic-gate 
5170Sstevel@tonic-gate 	/* Repository configuration */
5180Sstevel@tonic-gate 	pid_t		st_configd_pid;	/* PID of our svc.configd */
5190Sstevel@tonic-gate 					/* instance */
5200Sstevel@tonic-gate 	int		st_configd_lives; /* configd started */
5210Sstevel@tonic-gate 	pthread_mutex_t	st_configd_live_lock;
5220Sstevel@tonic-gate 	pthread_cond_t	st_configd_live_cv;
5230Sstevel@tonic-gate 
5240Sstevel@tonic-gate 	char		*st_door_path;
5250Sstevel@tonic-gate 
5260Sstevel@tonic-gate 	/* General information */
5270Sstevel@tonic-gate 	uint_t		st_flags;
5280Sstevel@tonic-gate 	struct timeval	st_start_time;	/* effective system start time */
5290Sstevel@tonic-gate 	char		*st_locale;
5300Sstevel@tonic-gate } startd_state_t;
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate extern startd_state_t *st;
5330Sstevel@tonic-gate 
5340Sstevel@tonic-gate extern boolean_t booting_to_single_user;
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate extern const char *event_names[];
5370Sstevel@tonic-gate 
5380Sstevel@tonic-gate /*
5390Sstevel@tonic-gate  * Structures for contract to instance hash table, implemented in
5400Sstevel@tonic-gate  * contract.c and used by restarter.c and method.c
5410Sstevel@tonic-gate  */
5420Sstevel@tonic-gate typedef struct contract_entry {
5430Sstevel@tonic-gate 	ctid_t		ce_ctid;
5440Sstevel@tonic-gate 	int		ce_instid;
5450Sstevel@tonic-gate 
5460Sstevel@tonic-gate 	uu_list_node_t	ce_link;
5470Sstevel@tonic-gate } contract_entry_t;
5480Sstevel@tonic-gate 
5494244Sjeanm extern volatile uint16_t	storing_contract;
5504244Sjeanm 
5510Sstevel@tonic-gate uu_list_pool_t *contract_list_pool;
5520Sstevel@tonic-gate 
5530Sstevel@tonic-gate /* contract.c */
5540Sstevel@tonic-gate ctid_t contract_init(void);
5550Sstevel@tonic-gate void contract_abandon(ctid_t);
5560Sstevel@tonic-gate int contract_kill(ctid_t, int, const char *);
5570Sstevel@tonic-gate int contract_is_empty(ctid_t);
5580Sstevel@tonic-gate void contract_hash_init();
5590Sstevel@tonic-gate void contract_hash_store(ctid_t, int);
5600Sstevel@tonic-gate void contract_hash_remove(ctid_t);
5610Sstevel@tonic-gate int lookup_inst_by_contract(ctid_t);
5620Sstevel@tonic-gate 
5630Sstevel@tonic-gate /* dict.c */
5640Sstevel@tonic-gate void dict_init(void);
5650Sstevel@tonic-gate int dict_lookup_byname(const char *);
5660Sstevel@tonic-gate int dict_insert(const char *);
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate /* expand.c */
5690Sstevel@tonic-gate int expand_method_tokens(const char *, scf_instance_t *,
5700Sstevel@tonic-gate     scf_snapshot_t *, int, char **);
5710Sstevel@tonic-gate 
5720Sstevel@tonic-gate /* env.c */
5730Sstevel@tonic-gate void init_env(void);
5740Sstevel@tonic-gate char **set_smf_env(char **, size_t, const char *,
5750Sstevel@tonic-gate     const restarter_inst_t *, const char *);
5760Sstevel@tonic-gate 
5770Sstevel@tonic-gate /* file.c */
5780Sstevel@tonic-gate int file_ready(graph_vertex_t *);
5790Sstevel@tonic-gate 
5800Sstevel@tonic-gate /* fork.c */
5810Sstevel@tonic-gate int fork_mount(char *, char *);
5820Sstevel@tonic-gate void fork_sulogin(boolean_t, const char *, ...);
5830Sstevel@tonic-gate void fork_rc_script(char, const char *, boolean_t);
5840Sstevel@tonic-gate 
5850Sstevel@tonic-gate void *fork_configd_thread(void *);
5860Sstevel@tonic-gate 
5870Sstevel@tonic-gate pid_t startd_fork1(int *);
5880Sstevel@tonic-gate 
5890Sstevel@tonic-gate /* graph.c */
5900Sstevel@tonic-gate void graph_init(void);
5910Sstevel@tonic-gate void *single_user_thread(void *);
5920Sstevel@tonic-gate void *graph_thread(void *);
5930Sstevel@tonic-gate void *graph_event_thread(void *);
5940Sstevel@tonic-gate void *repository_event_thread(void *);
5950Sstevel@tonic-gate int dgraph_add_instance(const char *, scf_instance_t *, boolean_t);
5960Sstevel@tonic-gate void graph_engine_start(void);
5971958Slianep void graph_enable_by_vertex(graph_vertex_t *, int, int);
5981958Slianep int refresh_vertex(graph_vertex_t *, scf_instance_t *);
5991958Slianep void vertex_send_event(graph_vertex_t *, restarter_event_type_t);
6001958Slianep void graph_start_if_satisfied(graph_vertex_t *);
6012747Sbustos int vertex_subgraph_dependencies_shutdown(scf_handle_t *, graph_vertex_t *,
6022747Sbustos     restarter_instance_state_t);
6031958Slianep void graph_transition_sulogin(restarter_instance_state_t,
6041958Slianep     restarter_instance_state_t);
6052339Slianep void graph_transition_propagate(graph_vertex_t *, propagate_event_t,
6061958Slianep     restarter_error_t);
6070Sstevel@tonic-gate 
6080Sstevel@tonic-gate /* libscf.c - common */
6090Sstevel@tonic-gate char *inst_fmri_to_svc_fmri(const char *);
6100Sstevel@tonic-gate void *libscf_object_create(void *(*)(scf_handle_t *), scf_handle_t *);
6110Sstevel@tonic-gate int libscf_instance_get_fmri(scf_instance_t *, char **);
6120Sstevel@tonic-gate int libscf_fmri_get_instance(scf_handle_t *, const char *, scf_instance_t **);
6130Sstevel@tonic-gate int libscf_lookup_instance(const char *, scf_instance_t *);
6140Sstevel@tonic-gate int libscf_set_reconfig(int);
6150Sstevel@tonic-gate scf_snapshot_t *libscf_get_or_make_running_snapshot(scf_instance_t *,
6160Sstevel@tonic-gate     const char *, boolean_t);
6170Sstevel@tonic-gate int libscf_inst_set_count_prop(scf_instance_t *, const char *,
6180Sstevel@tonic-gate     const char *pgtype, uint32_t, const char *, uint64_t);
6190Sstevel@tonic-gate 
6200Sstevel@tonic-gate /* libscf.c - used by graph.c */
6210Sstevel@tonic-gate int libscf_get_basic_instance_data(scf_handle_t *, scf_instance_t *,
6220Sstevel@tonic-gate     const char *, int *, int *, char **);
6230Sstevel@tonic-gate int libscf_inst_get_or_add_pg(scf_instance_t *, const char *, const char *,
6240Sstevel@tonic-gate     uint32_t, scf_propertygroup_t *);
6250Sstevel@tonic-gate int libscf_read_states(const scf_propertygroup_t *,
6260Sstevel@tonic-gate     restarter_instance_state_t *, restarter_instance_state_t *);
6270Sstevel@tonic-gate int depgroup_empty(scf_handle_t *, scf_propertygroup_t *);
6280Sstevel@tonic-gate gv_type_t depgroup_read_scheme(scf_handle_t *, scf_propertygroup_t *);
6290Sstevel@tonic-gate depgroup_type_t depgroup_read_grouping(scf_handle_t *, scf_propertygroup_t *);
6300Sstevel@tonic-gate restarter_error_t depgroup_read_restart(scf_handle_t *, scf_propertygroup_t *);
6310Sstevel@tonic-gate int libscf_set_enable_ovr(scf_instance_t *, int);
6320Sstevel@tonic-gate int libscf_inst_delete_prop(scf_instance_t *, const char *, const char *);
6330Sstevel@tonic-gate int libscf_delete_enable_ovr(scf_instance_t *);
6340Sstevel@tonic-gate int libscf_get_milestone(scf_instance_t *, scf_property_t *, scf_value_t *,
6350Sstevel@tonic-gate     char *, size_t);
6360Sstevel@tonic-gate int libscf_extract_runlevel(scf_property_t *, char *);
6370Sstevel@tonic-gate int libscf_clear_runlevel(scf_propertygroup_t *, const char *milestone);
6380Sstevel@tonic-gate 
6390Sstevel@tonic-gate typedef int (*callback_t)(void *, void *);
6400Sstevel@tonic-gate 
6410Sstevel@tonic-gate int walk_dependency_pgs(scf_instance_t *, callback_t, void *);
6420Sstevel@tonic-gate int walk_property_astrings(scf_property_t *, callback_t, void *);
6430Sstevel@tonic-gate 
6440Sstevel@tonic-gate /* libscf.c - used by restarter.c/method.c/expand.c */
6450Sstevel@tonic-gate char *libscf_get_method(scf_handle_t *, int, restarter_inst_t *,
6460Sstevel@tonic-gate     scf_snapshot_t *, method_restart_t *, uint_t *, uint8_t *, uint64_t *,
6470Sstevel@tonic-gate     uint8_t *);
6480Sstevel@tonic-gate void libscf_populate_graph(scf_handle_t *h);
6490Sstevel@tonic-gate int update_fault_count(restarter_inst_t *, int);
6500Sstevel@tonic-gate int libscf_unset_action(scf_handle_t *, scf_propertygroup_t *, admin_action_t,
6510Sstevel@tonic-gate     int64_t);
6520Sstevel@tonic-gate int libscf_get_startd_properties(scf_instance_t *, scf_snapshot_t *, uint_t *,
6530Sstevel@tonic-gate     char **);
6540Sstevel@tonic-gate int libscf_get_template_values(scf_instance_t *, scf_snapshot_t *, char **,
6550Sstevel@tonic-gate     char **);
6560Sstevel@tonic-gate 
6570Sstevel@tonic-gate int libscf_read_method_ids(scf_handle_t *, scf_instance_t *, const char *,
6580Sstevel@tonic-gate     ctid_t *, ctid_t *, pid_t *);
6590Sstevel@tonic-gate int libscf_write_start_pid(scf_instance_t *, pid_t);
6600Sstevel@tonic-gate int libscf_write_method_status(scf_instance_t *, const char *, int);
6610Sstevel@tonic-gate int libscf_note_method_log(scf_instance_t *, const char *, const char *);
6620Sstevel@tonic-gate 
6630Sstevel@tonic-gate scf_handle_t *libscf_handle_create_bound(scf_version_t);
6640Sstevel@tonic-gate void libscf_handle_rebind(scf_handle_t *);
6650Sstevel@tonic-gate scf_handle_t *libscf_handle_create_bound_loop(void);
6660Sstevel@tonic-gate 
6670Sstevel@tonic-gate scf_snapshot_t *libscf_get_running_snapshot(scf_instance_t *);
6680Sstevel@tonic-gate int libscf_snapshots_poststart(scf_handle_t *, const char *, boolean_t);
6690Sstevel@tonic-gate int libscf_snapshots_refresh(scf_instance_t *, const char *);
6700Sstevel@tonic-gate 
6710Sstevel@tonic-gate int instance_is_transient_style(restarter_inst_t *);
6720Sstevel@tonic-gate int instance_is_wait_style(restarter_inst_t *);
6730Sstevel@tonic-gate 
6740Sstevel@tonic-gate int libscf_create_self(scf_handle_t *);
6750Sstevel@tonic-gate 
6760Sstevel@tonic-gate void libscf_reget_instance(restarter_inst_t *);
6770Sstevel@tonic-gate 
6780Sstevel@tonic-gate /* log.c */
6790Sstevel@tonic-gate void log_init();
6800Sstevel@tonic-gate void log_error(int, const char *, ...);
6810Sstevel@tonic-gate void log_framework(int, const char *, ...);
682*5680Srm88369 void log_framework2(int, int, const char *, ...);
6830Sstevel@tonic-gate void log_console(int, const char *, ...);
6840Sstevel@tonic-gate void log_preexec(void);
6850Sstevel@tonic-gate void setlog(const char *);
6860Sstevel@tonic-gate void log_transition(const restarter_inst_t *, start_outcome_t);
6870Sstevel@tonic-gate void log_instance(const restarter_inst_t *, boolean_t, const char *, ...);
6880Sstevel@tonic-gate void log_instance_fmri(const char *, const char *, boolean_t,
6890Sstevel@tonic-gate     const char *, ...);
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate /* method.c */
6920Sstevel@tonic-gate void *method_thread(void *);
6930Sstevel@tonic-gate void method_remove_contract(restarter_inst_t *, boolean_t, boolean_t);
6940Sstevel@tonic-gate 
6950Sstevel@tonic-gate /* misc.c */
6960Sstevel@tonic-gate void startd_close(int);
6970Sstevel@tonic-gate void startd_fclose(FILE *);
6980Sstevel@tonic-gate int fmri_canonify(const char *, char **, boolean_t);
6990Sstevel@tonic-gate int fs_is_read_only(char *, ulong_t *);
7000Sstevel@tonic-gate int fs_remount(char *);
7010Sstevel@tonic-gate void xstr_sanitize(char *);
7020Sstevel@tonic-gate 
7030Sstevel@tonic-gate /* restarter.c */
7040Sstevel@tonic-gate void restarter_init(void);
7050Sstevel@tonic-gate void restarter_start(void);
7060Sstevel@tonic-gate int instance_in_transition(restarter_inst_t *);
7070Sstevel@tonic-gate int restarter_instance_update_states(scf_handle_t *, restarter_inst_t *,
7080Sstevel@tonic-gate     restarter_instance_state_t, restarter_instance_state_t, restarter_error_t,
7090Sstevel@tonic-gate     char *);
7100Sstevel@tonic-gate int stop_instance_fmri(scf_handle_t *, const char *, uint_t);
7110Sstevel@tonic-gate restarter_inst_t *inst_lookup_by_id(int);
7120Sstevel@tonic-gate void restarter_mark_pending_snapshot(const char *, uint_t);
7130Sstevel@tonic-gate void *restarter_post_fsminimal_thread(void *);
7140Sstevel@tonic-gate void timeout_insert(restarter_inst_t *, ctid_t, uint64_t);
7150Sstevel@tonic-gate void timeout_remove(restarter_inst_t *, ctid_t);
7160Sstevel@tonic-gate void timeout_init(void);
7170Sstevel@tonic-gate int is_timeout_ovr(restarter_inst_t *);
7180Sstevel@tonic-gate 
7190Sstevel@tonic-gate /* startd.c */
7200Sstevel@tonic-gate void *safe_realloc(void *, size_t);
7210Sstevel@tonic-gate char *safe_strdup(const char *s);
7220Sstevel@tonic-gate void *startd_alloc_retry(void *(*)(size_t, int), size_t);
7230Sstevel@tonic-gate void startd_free(void *, size_t);
7240Sstevel@tonic-gate uu_list_pool_t *startd_list_pool_create(const char *, size_t, size_t,
7250Sstevel@tonic-gate     uu_compare_fn_t *, uint32_t);
7260Sstevel@tonic-gate uu_list_t *startd_list_create(uu_list_pool_t *, void *, uint32_t);
7270Sstevel@tonic-gate pthread_t startd_thread_create(void *(*)(void *), void *);
7280Sstevel@tonic-gate 
7290Sstevel@tonic-gate /* special.c */
7300Sstevel@tonic-gate void special_null_transition(void);
7310Sstevel@tonic-gate void special_online_hooks_get(const char *, instance_hook_t *,
7320Sstevel@tonic-gate     instance_hook_t *, instance_hook_t *);
7330Sstevel@tonic-gate 
7341958Slianep /* transition.c */
7351958Slianep int gt_transition(scf_handle_t *, graph_vertex_t *, restarter_error_t,
7362339Slianep     restarter_instance_state_t);
7371958Slianep 
7380Sstevel@tonic-gate /* utmpx.c */
7390Sstevel@tonic-gate void utmpx_init(void);
7400Sstevel@tonic-gate void utmpx_clear_old(void);
7410Sstevel@tonic-gate int utmpx_mark_init(pid_t, char *);
7420Sstevel@tonic-gate void utmpx_mark_dead(pid_t, int, boolean_t);
7430Sstevel@tonic-gate char utmpx_get_runlevel(void);
7440Sstevel@tonic-gate void utmpx_set_runlevel(char, char, boolean_t);
7450Sstevel@tonic-gate void utmpx_write_boottime(void);
7460Sstevel@tonic-gate 
7470Sstevel@tonic-gate /* wait.c */
7480Sstevel@tonic-gate void wait_init(void);
7490Sstevel@tonic-gate void wait_prefork(void);
7500Sstevel@tonic-gate void wait_postfork(pid_t);
7510Sstevel@tonic-gate int wait_register(pid_t, const char *, int, int);
7520Sstevel@tonic-gate void *wait_thread(void *);
7530Sstevel@tonic-gate 
7540Sstevel@tonic-gate /* proc.c */
7550Sstevel@tonic-gate ctid_t proc_get_ctid();
7560Sstevel@tonic-gate 
7570Sstevel@tonic-gate #ifdef	__cplusplus
7580Sstevel@tonic-gate }
7590Sstevel@tonic-gate #endif
7600Sstevel@tonic-gate 
7610Sstevel@tonic-gate #endif	/* _STARTD_H */
762