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