1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _STARTD_H 28*0Sstevel@tonic-gate #define _STARTD_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/time.h> 33*0Sstevel@tonic-gate #include <librestart.h> 34*0Sstevel@tonic-gate #include <librestart_priv.h> 35*0Sstevel@tonic-gate #include <libscf.h> 36*0Sstevel@tonic-gate #include <libsysevent.h> 37*0Sstevel@tonic-gate #include <libuutil.h> 38*0Sstevel@tonic-gate #include <pthread.h> 39*0Sstevel@tonic-gate #include <stdio.h> 40*0Sstevel@tonic-gate #include <syslog.h> 41*0Sstevel@tonic-gate #include <umem.h> 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #ifdef __cplusplus 44*0Sstevel@tonic-gate extern "C" { 45*0Sstevel@tonic-gate #endif 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate /* 48*0Sstevel@tonic-gate * We want MUTEX_HELD, but we also want pthreads. So we're stuck with this. 49*0Sstevel@tonic-gate */ 50*0Sstevel@tonic-gate #define PTHREAD_MUTEX_HELD(m) _mutex_held((struct _lwp_mutex *)(m)) 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #ifndef NDEBUG 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate #define MUTEX_LOCK(mp) { \ 55*0Sstevel@tonic-gate int err; \ 56*0Sstevel@tonic-gate if ((err = pthread_mutex_lock((mp))) != 0) { \ 57*0Sstevel@tonic-gate (void) fprintf(stderr, \ 58*0Sstevel@tonic-gate "pthread_mutex_lock() failed on %s:%d: %s\n", \ 59*0Sstevel@tonic-gate __FILE__, __LINE__, strerror(err)); \ 60*0Sstevel@tonic-gate abort(); \ 61*0Sstevel@tonic-gate } \ 62*0Sstevel@tonic-gate } 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate #define MUTEX_UNLOCK(mp) { \ 65*0Sstevel@tonic-gate int err; \ 66*0Sstevel@tonic-gate if ((err = pthread_mutex_unlock((mp))) != 0) { \ 67*0Sstevel@tonic-gate (void) fprintf(stderr, \ 68*0Sstevel@tonic-gate "pthread_mutex_unlock() failed on %s:%d: %s\n", \ 69*0Sstevel@tonic-gate __FILE__, __LINE__, strerror(err)); \ 70*0Sstevel@tonic-gate abort(); \ 71*0Sstevel@tonic-gate } \ 72*0Sstevel@tonic-gate } 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate #else 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate #define MUTEX_LOCK(mp) (void) pthread_mutex_lock((mp)) 77*0Sstevel@tonic-gate #define MUTEX_UNLOCK(mp) (void) pthread_mutex_unlock((mp)) 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate #endif 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate #ifndef NDEBUG 82*0Sstevel@tonic-gate #define bad_error(func, err) { \ 83*0Sstevel@tonic-gate (void) fprintf(stderr, "%s:%d: %s() failed with unexpected " \ 84*0Sstevel@tonic-gate "error %d. Aborting.\n", __FILE__, __LINE__, (func), (err)); \ 85*0Sstevel@tonic-gate abort(); \ 86*0Sstevel@tonic-gate } 87*0Sstevel@tonic-gate #else 88*0Sstevel@tonic-gate #define bad_error(func, err) abort() 89*0Sstevel@tonic-gate #endif 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate #define min(a, b) (((a) < (b)) ? (a) : (b)) 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate #define FAULT_COUNT_INCR 0 95*0Sstevel@tonic-gate #define FAULT_COUNT_RESET 1 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate #define FAULT_THRESHOLD 3 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate #define MAX_CONFIGD_RETRIES 5 100*0Sstevel@tonic-gate #define MAX_MOUNT_RETRIES 5 101*0Sstevel@tonic-gate #define MAX_SULOGIN_RETRIES 5 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #define RETURN_SUCCESS 0 104*0Sstevel@tonic-gate #define RETURN_RETRY -1 105*0Sstevel@tonic-gate #define RETURN_FATAL -2 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate #define LIBSCF_SUCCESS 0 108*0Sstevel@tonic-gate #define LIBSCF_PROPERTY_ABSENT -1 109*0Sstevel@tonic-gate #define LIBSCF_PGROUP_ABSENT -2 110*0Sstevel@tonic-gate #define LIBSCF_PROPERTY_ERROR -3 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate #define METHOD_START 0 113*0Sstevel@tonic-gate #define METHOD_STOP 1 114*0Sstevel@tonic-gate #define METHOD_REFRESH 2 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate #define METHOD_TIMEOUT_INFINITE 0 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * Contract cookies used by startd. 120*0Sstevel@tonic-gate */ 121*0Sstevel@tonic-gate #define CONFIGD_COOKIE 0x10 122*0Sstevel@tonic-gate #define SULOGIN_COOKIE 0x11 123*0Sstevel@tonic-gate #define METHOD_START_COOKIE 0x20 124*0Sstevel@tonic-gate #define METHOD_OTHER_COOKIE 0x21 125*0Sstevel@tonic-gate #define MONITOR_COOKIE 0x30 126*0Sstevel@tonic-gate 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate #define ALLOC_RETRY 3 129*0Sstevel@tonic-gate #define ALLOC_DELAY 10 130*0Sstevel@tonic-gate #define ALLOC_DELAY_MULT 10 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate #define safe_scf_scope_create(h) \ 133*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_scope_create, (h)) 134*0Sstevel@tonic-gate #define safe_scf_service_create(h) \ 135*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_service_create, (h)) 136*0Sstevel@tonic-gate #define safe_scf_instance_create(h) libscf_object_create( \ 137*0Sstevel@tonic-gate (void *(*)(scf_handle_t *))scf_instance_create, (h)) 138*0Sstevel@tonic-gate #define safe_scf_snapshot_create(h) libscf_object_create( \ 139*0Sstevel@tonic-gate (void *(*)(scf_handle_t *))scf_snapshot_create, (h)) 140*0Sstevel@tonic-gate #define safe_scf_snaplevel_create(h) libscf_object_create( \ 141*0Sstevel@tonic-gate (void *(*)(scf_handle_t *))scf_snaplevel_create, (h)) 142*0Sstevel@tonic-gate #define safe_scf_pg_create(h) \ 143*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_pg_create, (h)) 144*0Sstevel@tonic-gate #define safe_scf_property_create(h) libscf_object_create( \ 145*0Sstevel@tonic-gate (void *(*)(scf_handle_t *))scf_property_create, (h)) 146*0Sstevel@tonic-gate #define safe_scf_value_create(h) \ 147*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_value_create, (h)) 148*0Sstevel@tonic-gate #define safe_scf_iter_create(h) \ 149*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_iter_create, (h)) 150*0Sstevel@tonic-gate #define safe_scf_transaction_create(h) libscf_object_create( \ 151*0Sstevel@tonic-gate (void *(*)(scf_handle_t *)) scf_transaction_create, (h)) 152*0Sstevel@tonic-gate #define safe_scf_entry_create(h) \ 153*0Sstevel@tonic-gate libscf_object_create((void *(*)(scf_handle_t *))scf_entry_create, (h)) 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate #define startd_alloc(sz) \ 156*0Sstevel@tonic-gate startd_alloc_retry((void *(*)(size_t, int))umem_alloc, (sz)) 157*0Sstevel@tonic-gate #define startd_zalloc(sz) \ 158*0Sstevel@tonic-gate startd_alloc_retry((void *(*)(size_t, int))umem_zalloc, (sz)) 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate extern pthread_mutexattr_t mutex_attrs; 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate /* 164*0Sstevel@tonic-gate * Definitions for administrative actions. 165*0Sstevel@tonic-gate * Note that the ordering in admin_action_t, admin_actions, and admin_events 166*0Sstevel@tonic-gate * must match. admin_actions and admin_events are defined in startd.c. 167*0Sstevel@tonic-gate */ 168*0Sstevel@tonic-gate #define NACTIONS 6 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate typedef enum { 171*0Sstevel@tonic-gate ADMIN_EVENT_DEGRADED = 0x0, 172*0Sstevel@tonic-gate ADMIN_EVENT_MAINT_OFF, 173*0Sstevel@tonic-gate ADMIN_EVENT_MAINT_ON, 174*0Sstevel@tonic-gate ADMIN_EVENT_MAINT_ON_IMMEDIATE, 175*0Sstevel@tonic-gate ADMIN_EVENT_REFRESH, 176*0Sstevel@tonic-gate ADMIN_EVENT_RESTART 177*0Sstevel@tonic-gate } admin_action_t; 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate extern const char * const admin_actions[NACTIONS]; 180*0Sstevel@tonic-gate extern const int admin_events[NACTIONS]; 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate #define LOG_DATE_SIZE 32 /* Max size of timestamp in log output */ 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate extern ssize_t max_scf_name_size; 185*0Sstevel@tonic-gate extern ssize_t max_scf_value_size; 186*0Sstevel@tonic-gate extern ssize_t max_scf_fmri_size; 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate extern mode_t fmask; 189*0Sstevel@tonic-gate extern mode_t dmask; 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate #define LOG_PREFIX_EARLY "/etc/svc/volatile/" 192*0Sstevel@tonic-gate #define LOG_PREFIX_NORMAL "/var/svc/log/" 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate #define LOG_SUFFIX ".log" 195*0Sstevel@tonic-gate 196*0Sstevel@tonic-gate #define STARTD_DEFAULT_LOG "svc.startd.log" 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate extern const char *log_directory; /* Current log directory path */ 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gate #define FS_TIMEZONE_DIR "/usr/share/lib/zoneinfo" 201*0Sstevel@tonic-gate #define FS_LOCALE_DIR "/usr/lib/locale" 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate /* 204*0Sstevel@tonic-gate * Simple dictionary representation. 205*0Sstevel@tonic-gate */ 206*0Sstevel@tonic-gate typedef struct dictionary { 207*0Sstevel@tonic-gate uu_list_t *dict_list; 208*0Sstevel@tonic-gate int dict_new_id; 209*0Sstevel@tonic-gate pthread_mutex_t dict_lock; 210*0Sstevel@tonic-gate } dictionary_t; 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate typedef struct dict_entry { 213*0Sstevel@tonic-gate int de_id; 214*0Sstevel@tonic-gate const char *de_name; 215*0Sstevel@tonic-gate uu_list_node_t de_link; 216*0Sstevel@tonic-gate } dict_entry_t; 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate extern dictionary_t *dictionary; 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate typedef struct timeout_queue { 221*0Sstevel@tonic-gate uu_list_t *tq_list; 222*0Sstevel@tonic-gate pthread_mutex_t tq_lock; 223*0Sstevel@tonic-gate } timeout_queue_t; 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate typedef struct timeout_entry { 226*0Sstevel@tonic-gate hrtime_t te_timeout; /* timeout expiration time */ 227*0Sstevel@tonic-gate ctid_t te_ctid; 228*0Sstevel@tonic-gate char *te_fmri; 229*0Sstevel@tonic-gate char *te_logstem; 230*0Sstevel@tonic-gate volatile int te_fired; 231*0Sstevel@tonic-gate uu_list_node_t te_link; 232*0Sstevel@tonic-gate } timeout_entry_t; 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate extern timeout_queue_t *timeouts; 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate /* 237*0Sstevel@tonic-gate * State definitions. 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate typedef enum { 240*0Sstevel@tonic-gate STATE_NONE = 0x0, 241*0Sstevel@tonic-gate STATE_UNINIT, 242*0Sstevel@tonic-gate STATE_MAINT, 243*0Sstevel@tonic-gate STATE_OFFLINE, 244*0Sstevel@tonic-gate STATE_DISABLED, 245*0Sstevel@tonic-gate STATE_ONLINE, 246*0Sstevel@tonic-gate STATE_DEGRADED 247*0Sstevel@tonic-gate } instance_state_t; 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate #define STATE_MAX (STATE_DEGRADED + 1) 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate extern const char * const instance_state_str[STATE_MAX]; 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate typedef enum { 254*0Sstevel@tonic-gate GVT_UNSUPPORTED = -1, 255*0Sstevel@tonic-gate GVT_UNKNOWN = 0, 256*0Sstevel@tonic-gate GVT_SVC, /* service */ 257*0Sstevel@tonic-gate GVT_INST, /* instance */ 258*0Sstevel@tonic-gate GVT_FILE, /* file: */ 259*0Sstevel@tonic-gate GVT_GROUP /* dependency group */ 260*0Sstevel@tonic-gate } gv_type_t; 261*0Sstevel@tonic-gate 262*0Sstevel@tonic-gate typedef enum { 263*0Sstevel@tonic-gate DEPGRP_UNSUPPORTED = -1, 264*0Sstevel@tonic-gate DEPGRP_REQUIRE_ANY = 1, 265*0Sstevel@tonic-gate DEPGRP_REQUIRE_ALL, 266*0Sstevel@tonic-gate DEPGRP_EXCLUDE_ALL, 267*0Sstevel@tonic-gate DEPGRP_OPTIONAL_ALL 268*0Sstevel@tonic-gate } depgroup_type_t; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate typedef enum { 271*0Sstevel@tonic-gate METHOD_RESTART_UNKNOWN = -1, 272*0Sstevel@tonic-gate METHOD_RESTART_ALL = 0, 273*0Sstevel@tonic-gate METHOD_RESTART_EXTERNAL_FAULT, 274*0Sstevel@tonic-gate METHOD_RESTART_ANY_FAULT, 275*0Sstevel@tonic-gate METHOD_RESTART_OTHER 276*0Sstevel@tonic-gate } method_restart_t; 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate /* 279*0Sstevel@tonic-gate * Graph representation. 280*0Sstevel@tonic-gate */ 281*0Sstevel@tonic-gate #define GV_CONFIGURED 0x01 /* Service exists in repository, ready */ 282*0Sstevel@tonic-gate #define GV_ENABLED 0x02 /* Service should be online */ 283*0Sstevel@tonic-gate #define GV_ENBLD_NOOVR 0x04 /* GV_ENABLED, ignoring override */ 284*0Sstevel@tonic-gate #define GV_INSUBGRAPH 0x08 /* Current milestone depends on service */ 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate /* ID must come first to support search */ 287*0Sstevel@tonic-gate typedef struct graph_vertex { 288*0Sstevel@tonic-gate int gv_id; 289*0Sstevel@tonic-gate char *gv_name; 290*0Sstevel@tonic-gate uu_list_node_t gv_link; 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate uint_t gv_flags; 293*0Sstevel@tonic-gate restarter_instance_state_t gv_state; 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gate gv_type_t gv_type; 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate depgroup_type_t gv_depgroup; 298*0Sstevel@tonic-gate restarter_error_t gv_restart; 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate void (*gv_start_f)(struct graph_vertex *); 301*0Sstevel@tonic-gate void (*gv_post_online_f)(void); 302*0Sstevel@tonic-gate void (*gv_post_disable_f)(void); 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate int gv_restarter_id; 305*0Sstevel@tonic-gate evchan_t *gv_restarter_channel; 306*0Sstevel@tonic-gate 307*0Sstevel@tonic-gate int gv_delegate_initialized; 308*0Sstevel@tonic-gate evchan_t *gv_delegate_channel; 309*0Sstevel@tonic-gate 310*0Sstevel@tonic-gate uu_list_t *gv_dependencies; 311*0Sstevel@tonic-gate uu_list_t *gv_dependents; 312*0Sstevel@tonic-gate } graph_vertex_t; 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate typedef struct graph_edge { 315*0Sstevel@tonic-gate graph_vertex_t *ge_vertex; 316*0Sstevel@tonic-gate uu_list_node_t ge_link; 317*0Sstevel@tonic-gate graph_vertex_t *ge_parent; 318*0Sstevel@tonic-gate } graph_edge_t; 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate /* 322*0Sstevel@tonic-gate * Start method outcomes 323*0Sstevel@tonic-gate */ 324*0Sstevel@tonic-gate typedef enum { 325*0Sstevel@tonic-gate START_REQUESTED, 326*0Sstevel@tonic-gate START_FAILED_REPEATEDLY, 327*0Sstevel@tonic-gate START_FAILED_CONFIGURATION, 328*0Sstevel@tonic-gate START_FAILED_FATAL, 329*0Sstevel@tonic-gate START_FAILED_TIMEOUT_FATAL, 330*0Sstevel@tonic-gate START_FAILED_OTHER 331*0Sstevel@tonic-gate } start_outcome_t; 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate typedef void (*instance_hook_t)(void); 334*0Sstevel@tonic-gate 335*0Sstevel@tonic-gate typedef struct service_hook_assn { 336*0Sstevel@tonic-gate char *sh_fmri; 337*0Sstevel@tonic-gate instance_hook_t sh_pre_online_hook; 338*0Sstevel@tonic-gate instance_hook_t sh_post_online_hook; 339*0Sstevel@tonic-gate instance_hook_t sh_post_offline_hook; 340*0Sstevel@tonic-gate } service_hook_assn_t; 341*0Sstevel@tonic-gate 342*0Sstevel@tonic-gate /* 343*0Sstevel@tonic-gate * Restarter instance stop reasons. 344*0Sstevel@tonic-gate */ 345*0Sstevel@tonic-gate typedef enum { 346*0Sstevel@tonic-gate RSTOP_EXIT = 0x0, /* exited or empty */ 347*0Sstevel@tonic-gate RSTOP_CORE, /* core dumped */ 348*0Sstevel@tonic-gate RSTOP_SIGNAL, /* external fatal signal received */ 349*0Sstevel@tonic-gate RSTOP_HWERR, /* uncorrectable hardware error */ 350*0Sstevel@tonic-gate RSTOP_DEPENDENCY, /* dependency activity caused stop */ 351*0Sstevel@tonic-gate RSTOP_DISABLE, /* disabled */ 352*0Sstevel@tonic-gate RSTOP_RESTART /* restart requested */ 353*0Sstevel@tonic-gate } stop_cause_t; 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gate /* 356*0Sstevel@tonic-gate * Restarter instance maintenance clear reasons. 357*0Sstevel@tonic-gate */ 358*0Sstevel@tonic-gate typedef enum { 359*0Sstevel@tonic-gate RUNMAINT_CLEAR = 0x0, 360*0Sstevel@tonic-gate RUNMAINT_DISABLE 361*0Sstevel@tonic-gate } unmaint_cause_t; 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gate /* 364*0Sstevel@tonic-gate * Restarter instance flags 365*0Sstevel@tonic-gate */ 366*0Sstevel@tonic-gate #define RINST_CONTRACT 0x00000000 /* progeny constitute inst */ 367*0Sstevel@tonic-gate #define RINST_TRANSIENT 0x10000000 /* inst operates momentarily */ 368*0Sstevel@tonic-gate #define RINST_WAIT 0x20000000 /* child constitutes inst */ 369*0Sstevel@tonic-gate #define RINST_STYLE_MASK 0xf0000000 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gate #define RINST_RETAKE_RUNNING 0x01000000 /* pending running snapshot */ 372*0Sstevel@tonic-gate #define RINST_RETAKE_START 0x02000000 /* pending start snapshot */ 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate #define RINST_RETAKE_MASK 0x0f000000 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate #define RINST_START_TIMES 10 /* failures to consider */ 377*0Sstevel@tonic-gate #define RINST_FAILURE_RATE_NS 1000000000LL /* 1 failure/second */ 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate /* Number of events in the queue when we start dropping ADMIN events. */ 380*0Sstevel@tonic-gate #define RINST_QUEUE_THRESHOLD 100 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gate typedef struct restarter_inst { 383*0Sstevel@tonic-gate int ri_id; 384*0Sstevel@tonic-gate instance_data_t ri_i; 385*0Sstevel@tonic-gate char *ri_common_name; /* template localized name */ 386*0Sstevel@tonic-gate char *ri_C_common_name; /* C locale name */ 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gate char *ri_logstem; /* logfile name */ 389*0Sstevel@tonic-gate char *ri_utmpx_prefix; 390*0Sstevel@tonic-gate uint_t ri_flags; 391*0Sstevel@tonic-gate instance_hook_t ri_pre_online_hook; 392*0Sstevel@tonic-gate instance_hook_t ri_post_online_hook; 393*0Sstevel@tonic-gate instance_hook_t ri_post_offline_hook; 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate hrtime_t ri_start_time[RINST_START_TIMES]; 396*0Sstevel@tonic-gate uint_t ri_start_index; /* times started */ 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate uu_list_node_t ri_link; 399*0Sstevel@tonic-gate pthread_mutex_t ri_lock; 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gate /* 402*0Sstevel@tonic-gate * When we start a thread to we execute a method for this instance, we 403*0Sstevel@tonic-gate * put the thread id in ri_method_thread. Threads with ids other than 404*0Sstevel@tonic-gate * this which acquire ri_lock while ri_method_thread is nonzero should 405*0Sstevel@tonic-gate * wait on ri_method_cv. ri_method_waiters should be incremented while 406*0Sstevel@tonic-gate * waiting so the instance won't be deleted. 407*0Sstevel@tonic-gate */ 408*0Sstevel@tonic-gate pthread_t ri_method_thread; 409*0Sstevel@tonic-gate pthread_cond_t ri_method_cv; 410*0Sstevel@tonic-gate uint_t ri_method_waiters; 411*0Sstevel@tonic-gate 412*0Sstevel@tonic-gate /* 413*0Sstevel@tonic-gate * These fields are provided so functions can operate on this structure 414*0Sstevel@tonic-gate * and the repository without worrying about whether the instance has 415*0Sstevel@tonic-gate * been deleted from the repository (this is possible because 416*0Sstevel@tonic-gate * ri_i.i_fmri names the instance this structure represents -- see 417*0Sstevel@tonic-gate * libscf_reget_inst()). ri_m_inst is the scf_instance_t for the 418*0Sstevel@tonic-gate * instance, and ri_mi_deleted is true if the instance has been deleted. 419*0Sstevel@tonic-gate */ 420*0Sstevel@tonic-gate scf_instance_t *ri_m_inst; 421*0Sstevel@tonic-gate boolean_t ri_mi_deleted; 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate /* 424*0Sstevel@tonic-gate * We maintain a pointer to any pending timeout for this instance 425*0Sstevel@tonic-gate * for quick reference/deletion. 426*0Sstevel@tonic-gate */ 427*0Sstevel@tonic-gate timeout_entry_t *ri_timeout; 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate /* 430*0Sstevel@tonic-gate * Instance event queue. Graph events are queued here as a list 431*0Sstevel@tonic-gate * of restarter_instance_qentry_t's, and the lock is held separately. 432*0Sstevel@tonic-gate * If both ri_lock and ri_queue_lock are grabbed, ri_lock must be 433*0Sstevel@tonic-gate * grabbed first. ri_queue_lock protects all ri_queue_* structure 434*0Sstevel@tonic-gate * members. 435*0Sstevel@tonic-gate */ 436*0Sstevel@tonic-gate pthread_mutex_t ri_queue_lock; 437*0Sstevel@tonic-gate pthread_cond_t ri_queue_cv; 438*0Sstevel@tonic-gate uu_list_t *ri_queue; 439*0Sstevel@tonic-gate int ri_queue_thread; 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate } restarter_inst_t; 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate typedef struct restarter_instance_list { 444*0Sstevel@tonic-gate uu_list_t *ril_instance_list; 445*0Sstevel@tonic-gate pthread_mutex_t ril_lock; 446*0Sstevel@tonic-gate } restarter_instance_list_t; 447*0Sstevel@tonic-gate 448*0Sstevel@tonic-gate typedef struct restarter_instance_qentry { 449*0Sstevel@tonic-gate restarter_event_type_t riq_type; 450*0Sstevel@tonic-gate uu_list_node_t riq_link; 451*0Sstevel@tonic-gate } restarter_instance_qentry_t; 452*0Sstevel@tonic-gate 453*0Sstevel@tonic-gate typedef struct fork_info { 454*0Sstevel@tonic-gate int sf_id; 455*0Sstevel@tonic-gate int sf_method_type; 456*0Sstevel@tonic-gate restarter_error_t sf_event_type; 457*0Sstevel@tonic-gate } fork_info_t; 458*0Sstevel@tonic-gate 459*0Sstevel@tonic-gate typedef struct wait_info { 460*0Sstevel@tonic-gate uu_list_node_t wi_link; 461*0Sstevel@tonic-gate 462*0Sstevel@tonic-gate int wi_fd; /* psinfo file descriptor */ 463*0Sstevel@tonic-gate id_t wi_pid; /* process ID */ 464*0Sstevel@tonic-gate const char *wi_fmri; /* instance FMRI */ 465*0Sstevel@tonic-gate int wi_parent; /* startd is parent */ 466*0Sstevel@tonic-gate } wait_info_t; 467*0Sstevel@tonic-gate 468*0Sstevel@tonic-gate #define STARTD_LOG_FILE 0x1 469*0Sstevel@tonic-gate #define STARTD_LOG_TERMINAL 0x2 470*0Sstevel@tonic-gate #define STARTD_LOG_SYSLOG 0x4 471*0Sstevel@tonic-gate 472*0Sstevel@tonic-gate #define STARTD_BOOT 0x1 473*0Sstevel@tonic-gate #define STARTD_DEBUG 0x2 474*0Sstevel@tonic-gate 475*0Sstevel@tonic-gate #define STARTD_BOOT_QUIET 0x1 476*0Sstevel@tonic-gate #define STARTD_BOOT_VERBOSE 0x2 477*0Sstevel@tonic-gate 478*0Sstevel@tonic-gate #define STARTD_LOG_QUIET 0x1 479*0Sstevel@tonic-gate #define STARTD_LOG_VERBOSE 0x2 480*0Sstevel@tonic-gate #define STARTD_LOG_DEBUG 0x3 481*0Sstevel@tonic-gate 482*0Sstevel@tonic-gate typedef struct startd_state { 483*0Sstevel@tonic-gate /* Logging configuration */ 484*0Sstevel@tonic-gate char *st_log_prefix; /* directory prefix */ 485*0Sstevel@tonic-gate char *st_log_file; /* startd file in above dir */ 486*0Sstevel@tonic-gate uint_t st_log_flags; /* message destination */ 487*0Sstevel@tonic-gate int st_log_level_min; /* minimum required to log */ 488*0Sstevel@tonic-gate int st_log_timezone_known; /* timezone is available */ 489*0Sstevel@tonic-gate int st_log_locale_known; /* locale is available */ 490*0Sstevel@tonic-gate int st_log_login_reached; /* login service reached */ 491*0Sstevel@tonic-gate 492*0Sstevel@tonic-gate /* Boot configuration */ 493*0Sstevel@tonic-gate uint_t st_boot_flags; /* serial boot, etc. */ 494*0Sstevel@tonic-gate uint_t st_initial; /* first startd on system */ 495*0Sstevel@tonic-gate 496*0Sstevel@tonic-gate /* System configuration */ 497*0Sstevel@tonic-gate char *st_subgraph; /* milestone subgraph request */ 498*0Sstevel@tonic-gate 499*0Sstevel@tonic-gate uint_t st_load_complete; /* graph load completed */ 500*0Sstevel@tonic-gate uint_t st_load_instances; /* restarter instances to load */ 501*0Sstevel@tonic-gate pthread_mutex_t st_load_lock; 502*0Sstevel@tonic-gate pthread_cond_t st_load_cv; 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate /* Repository configuration */ 505*0Sstevel@tonic-gate pid_t st_configd_pid; /* PID of our svc.configd */ 506*0Sstevel@tonic-gate /* instance */ 507*0Sstevel@tonic-gate int st_configd_lives; /* configd started */ 508*0Sstevel@tonic-gate pthread_mutex_t st_configd_live_lock; 509*0Sstevel@tonic-gate pthread_cond_t st_configd_live_cv; 510*0Sstevel@tonic-gate 511*0Sstevel@tonic-gate char *st_door_path; 512*0Sstevel@tonic-gate 513*0Sstevel@tonic-gate /* General information */ 514*0Sstevel@tonic-gate uint_t st_flags; 515*0Sstevel@tonic-gate struct timeval st_start_time; /* effective system start time */ 516*0Sstevel@tonic-gate char *st_locale; 517*0Sstevel@tonic-gate } startd_state_t; 518*0Sstevel@tonic-gate 519*0Sstevel@tonic-gate extern startd_state_t *st; 520*0Sstevel@tonic-gate 521*0Sstevel@tonic-gate extern boolean_t booting_to_single_user; 522*0Sstevel@tonic-gate 523*0Sstevel@tonic-gate extern const char *event_names[]; 524*0Sstevel@tonic-gate 525*0Sstevel@tonic-gate /* 526*0Sstevel@tonic-gate * Structures for contract to instance hash table, implemented in 527*0Sstevel@tonic-gate * contract.c and used by restarter.c and method.c 528*0Sstevel@tonic-gate */ 529*0Sstevel@tonic-gate typedef struct contract_entry { 530*0Sstevel@tonic-gate ctid_t ce_ctid; 531*0Sstevel@tonic-gate int ce_instid; 532*0Sstevel@tonic-gate 533*0Sstevel@tonic-gate uu_list_node_t ce_link; 534*0Sstevel@tonic-gate } contract_entry_t; 535*0Sstevel@tonic-gate 536*0Sstevel@tonic-gate uu_list_pool_t *contract_list_pool; 537*0Sstevel@tonic-gate 538*0Sstevel@tonic-gate /* contract.c */ 539*0Sstevel@tonic-gate ctid_t contract_init(void); 540*0Sstevel@tonic-gate void contract_abandon(ctid_t); 541*0Sstevel@tonic-gate int contract_kill(ctid_t, int, const char *); 542*0Sstevel@tonic-gate int contract_is_empty(ctid_t); 543*0Sstevel@tonic-gate void contract_hash_init(); 544*0Sstevel@tonic-gate void contract_hash_store(ctid_t, int); 545*0Sstevel@tonic-gate void contract_hash_remove(ctid_t); 546*0Sstevel@tonic-gate int lookup_inst_by_contract(ctid_t); 547*0Sstevel@tonic-gate 548*0Sstevel@tonic-gate /* dict.c */ 549*0Sstevel@tonic-gate void dict_init(void); 550*0Sstevel@tonic-gate int dict_lookup_byname(const char *); 551*0Sstevel@tonic-gate int dict_insert(const char *); 552*0Sstevel@tonic-gate 553*0Sstevel@tonic-gate /* expand.c */ 554*0Sstevel@tonic-gate int expand_method_tokens(const char *, scf_instance_t *, 555*0Sstevel@tonic-gate scf_snapshot_t *, int, char **); 556*0Sstevel@tonic-gate 557*0Sstevel@tonic-gate /* env.c */ 558*0Sstevel@tonic-gate void init_env(void); 559*0Sstevel@tonic-gate char **set_smf_env(char **, size_t, const char *, 560*0Sstevel@tonic-gate const restarter_inst_t *, const char *); 561*0Sstevel@tonic-gate 562*0Sstevel@tonic-gate /* file.c */ 563*0Sstevel@tonic-gate int file_ready(graph_vertex_t *); 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate /* fork.c */ 566*0Sstevel@tonic-gate int fork_mount(char *, char *); 567*0Sstevel@tonic-gate void fork_sulogin(boolean_t, const char *, ...); 568*0Sstevel@tonic-gate void fork_rc_script(char, const char *, boolean_t); 569*0Sstevel@tonic-gate 570*0Sstevel@tonic-gate void *fork_configd_thread(void *); 571*0Sstevel@tonic-gate 572*0Sstevel@tonic-gate pid_t startd_fork1(int *); 573*0Sstevel@tonic-gate 574*0Sstevel@tonic-gate /* graph.c */ 575*0Sstevel@tonic-gate void graph_init(void); 576*0Sstevel@tonic-gate void *single_user_thread(void *); 577*0Sstevel@tonic-gate void *graph_thread(void *); 578*0Sstevel@tonic-gate void *graph_event_thread(void *); 579*0Sstevel@tonic-gate void *repository_event_thread(void *); 580*0Sstevel@tonic-gate int dgraph_add_instance(const char *, scf_instance_t *, boolean_t); 581*0Sstevel@tonic-gate void graph_engine_start(void); 582*0Sstevel@tonic-gate 583*0Sstevel@tonic-gate /* libscf.c - common */ 584*0Sstevel@tonic-gate char *inst_fmri_to_svc_fmri(const char *); 585*0Sstevel@tonic-gate void *libscf_object_create(void *(*)(scf_handle_t *), scf_handle_t *); 586*0Sstevel@tonic-gate int libscf_instance_get_fmri(scf_instance_t *, char **); 587*0Sstevel@tonic-gate int libscf_fmri_get_instance(scf_handle_t *, const char *, scf_instance_t **); 588*0Sstevel@tonic-gate int libscf_lookup_instance(const char *, scf_instance_t *); 589*0Sstevel@tonic-gate int libscf_set_reconfig(int); 590*0Sstevel@tonic-gate scf_snapshot_t *libscf_get_or_make_running_snapshot(scf_instance_t *, 591*0Sstevel@tonic-gate const char *, boolean_t); 592*0Sstevel@tonic-gate int libscf_inst_set_count_prop(scf_instance_t *, const char *, 593*0Sstevel@tonic-gate const char *pgtype, uint32_t, const char *, uint64_t); 594*0Sstevel@tonic-gate 595*0Sstevel@tonic-gate /* libscf.c - used by graph.c */ 596*0Sstevel@tonic-gate int libscf_get_basic_instance_data(scf_handle_t *, scf_instance_t *, 597*0Sstevel@tonic-gate const char *, int *, int *, char **); 598*0Sstevel@tonic-gate int libscf_inst_get_or_add_pg(scf_instance_t *, const char *, const char *, 599*0Sstevel@tonic-gate uint32_t, scf_propertygroup_t *); 600*0Sstevel@tonic-gate int libscf_read_states(const scf_propertygroup_t *, 601*0Sstevel@tonic-gate restarter_instance_state_t *, restarter_instance_state_t *); 602*0Sstevel@tonic-gate int depgroup_empty(scf_handle_t *, scf_propertygroup_t *); 603*0Sstevel@tonic-gate gv_type_t depgroup_read_scheme(scf_handle_t *, scf_propertygroup_t *); 604*0Sstevel@tonic-gate depgroup_type_t depgroup_read_grouping(scf_handle_t *, scf_propertygroup_t *); 605*0Sstevel@tonic-gate restarter_error_t depgroup_read_restart(scf_handle_t *, scf_propertygroup_t *); 606*0Sstevel@tonic-gate int libscf_set_enable_ovr(scf_instance_t *, int); 607*0Sstevel@tonic-gate int libscf_inst_delete_prop(scf_instance_t *, const char *, const char *); 608*0Sstevel@tonic-gate int libscf_delete_enable_ovr(scf_instance_t *); 609*0Sstevel@tonic-gate int libscf_get_milestone(scf_instance_t *, scf_property_t *, scf_value_t *, 610*0Sstevel@tonic-gate char *, size_t); 611*0Sstevel@tonic-gate int libscf_extract_runlevel(scf_property_t *, char *); 612*0Sstevel@tonic-gate int libscf_clear_runlevel(scf_propertygroup_t *, const char *milestone); 613*0Sstevel@tonic-gate 614*0Sstevel@tonic-gate typedef int (*callback_t)(void *, void *); 615*0Sstevel@tonic-gate 616*0Sstevel@tonic-gate int walk_dependency_pgs(scf_instance_t *, callback_t, void *); 617*0Sstevel@tonic-gate int walk_property_astrings(scf_property_t *, callback_t, void *); 618*0Sstevel@tonic-gate 619*0Sstevel@tonic-gate /* libscf.c - used by restarter.c/method.c/expand.c */ 620*0Sstevel@tonic-gate char *libscf_get_method(scf_handle_t *, int, restarter_inst_t *, 621*0Sstevel@tonic-gate scf_snapshot_t *, method_restart_t *, uint_t *, uint8_t *, uint64_t *, 622*0Sstevel@tonic-gate uint8_t *); 623*0Sstevel@tonic-gate void libscf_populate_graph(scf_handle_t *h); 624*0Sstevel@tonic-gate int update_fault_count(restarter_inst_t *, int); 625*0Sstevel@tonic-gate int libscf_unset_action(scf_handle_t *, scf_propertygroup_t *, admin_action_t, 626*0Sstevel@tonic-gate int64_t); 627*0Sstevel@tonic-gate int libscf_get_startd_properties(scf_instance_t *, scf_snapshot_t *, uint_t *, 628*0Sstevel@tonic-gate char **); 629*0Sstevel@tonic-gate int libscf_get_template_values(scf_instance_t *, scf_snapshot_t *, char **, 630*0Sstevel@tonic-gate char **); 631*0Sstevel@tonic-gate 632*0Sstevel@tonic-gate int libscf_read_method_ids(scf_handle_t *, scf_instance_t *, const char *, 633*0Sstevel@tonic-gate ctid_t *, ctid_t *, pid_t *); 634*0Sstevel@tonic-gate int libscf_write_start_pid(scf_instance_t *, pid_t); 635*0Sstevel@tonic-gate int libscf_write_method_status(scf_instance_t *, const char *, int); 636*0Sstevel@tonic-gate int libscf_note_method_log(scf_instance_t *, const char *, const char *); 637*0Sstevel@tonic-gate 638*0Sstevel@tonic-gate scf_handle_t *libscf_handle_create_bound(scf_version_t); 639*0Sstevel@tonic-gate void libscf_handle_rebind(scf_handle_t *); 640*0Sstevel@tonic-gate scf_handle_t *libscf_handle_create_bound_loop(void); 641*0Sstevel@tonic-gate 642*0Sstevel@tonic-gate scf_snapshot_t *libscf_get_running_snapshot(scf_instance_t *); 643*0Sstevel@tonic-gate int libscf_snapshots_poststart(scf_handle_t *, const char *, boolean_t); 644*0Sstevel@tonic-gate int libscf_snapshots_refresh(scf_instance_t *, const char *); 645*0Sstevel@tonic-gate 646*0Sstevel@tonic-gate int instance_is_transient_style(restarter_inst_t *); 647*0Sstevel@tonic-gate int instance_is_wait_style(restarter_inst_t *); 648*0Sstevel@tonic-gate 649*0Sstevel@tonic-gate int libscf_create_self(scf_handle_t *); 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gate void libscf_reget_instance(restarter_inst_t *); 652*0Sstevel@tonic-gate 653*0Sstevel@tonic-gate /* log.c */ 654*0Sstevel@tonic-gate void log_init(); 655*0Sstevel@tonic-gate void log_error(int, const char *, ...); 656*0Sstevel@tonic-gate void log_framework(int, const char *, ...); 657*0Sstevel@tonic-gate void log_console(int, const char *, ...); 658*0Sstevel@tonic-gate void log_preexec(void); 659*0Sstevel@tonic-gate void setlog(const char *); 660*0Sstevel@tonic-gate void log_transition(const restarter_inst_t *, start_outcome_t); 661*0Sstevel@tonic-gate void log_instance(const restarter_inst_t *, boolean_t, const char *, ...); 662*0Sstevel@tonic-gate void log_instance_fmri(const char *, const char *, boolean_t, 663*0Sstevel@tonic-gate const char *, ...); 664*0Sstevel@tonic-gate 665*0Sstevel@tonic-gate /* method.c */ 666*0Sstevel@tonic-gate void *method_thread(void *); 667*0Sstevel@tonic-gate void method_remove_contract(restarter_inst_t *, boolean_t, boolean_t); 668*0Sstevel@tonic-gate 669*0Sstevel@tonic-gate /* misc.c */ 670*0Sstevel@tonic-gate void startd_close(int); 671*0Sstevel@tonic-gate void startd_fclose(FILE *); 672*0Sstevel@tonic-gate int fmri_canonify(const char *, char **, boolean_t); 673*0Sstevel@tonic-gate int fs_is_read_only(char *, ulong_t *); 674*0Sstevel@tonic-gate int fs_remount(char *); 675*0Sstevel@tonic-gate void xstr_sanitize(char *); 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate /* restarter.c */ 678*0Sstevel@tonic-gate void restarter_init(void); 679*0Sstevel@tonic-gate void restarter_start(void); 680*0Sstevel@tonic-gate int instance_in_transition(restarter_inst_t *); 681*0Sstevel@tonic-gate int restarter_instance_update_states(scf_handle_t *, restarter_inst_t *, 682*0Sstevel@tonic-gate restarter_instance_state_t, restarter_instance_state_t, restarter_error_t, 683*0Sstevel@tonic-gate char *); 684*0Sstevel@tonic-gate int stop_instance_fmri(scf_handle_t *, const char *, uint_t); 685*0Sstevel@tonic-gate restarter_inst_t *inst_lookup_by_id(int); 686*0Sstevel@tonic-gate void restarter_mark_pending_snapshot(const char *, uint_t); 687*0Sstevel@tonic-gate void *restarter_post_fsminimal_thread(void *); 688*0Sstevel@tonic-gate void timeout_insert(restarter_inst_t *, ctid_t, uint64_t); 689*0Sstevel@tonic-gate void timeout_remove(restarter_inst_t *, ctid_t); 690*0Sstevel@tonic-gate void timeout_init(void); 691*0Sstevel@tonic-gate int is_timeout_ovr(restarter_inst_t *); 692*0Sstevel@tonic-gate 693*0Sstevel@tonic-gate /* startd.c */ 694*0Sstevel@tonic-gate void *safe_realloc(void *, size_t); 695*0Sstevel@tonic-gate char *safe_strdup(const char *s); 696*0Sstevel@tonic-gate void *startd_alloc_retry(void *(*)(size_t, int), size_t); 697*0Sstevel@tonic-gate void startd_free(void *, size_t); 698*0Sstevel@tonic-gate uu_list_pool_t *startd_list_pool_create(const char *, size_t, size_t, 699*0Sstevel@tonic-gate uu_compare_fn_t *, uint32_t); 700*0Sstevel@tonic-gate uu_list_t *startd_list_create(uu_list_pool_t *, void *, uint32_t); 701*0Sstevel@tonic-gate pthread_t startd_thread_create(void *(*)(void *), void *); 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate /* special.c */ 704*0Sstevel@tonic-gate void special_null_transition(void); 705*0Sstevel@tonic-gate void special_online_hooks_get(const char *, instance_hook_t *, 706*0Sstevel@tonic-gate instance_hook_t *, instance_hook_t *); 707*0Sstevel@tonic-gate 708*0Sstevel@tonic-gate /* utmpx.c */ 709*0Sstevel@tonic-gate void utmpx_init(void); 710*0Sstevel@tonic-gate void utmpx_clear_old(void); 711*0Sstevel@tonic-gate int utmpx_mark_init(pid_t, char *); 712*0Sstevel@tonic-gate void utmpx_mark_dead(pid_t, int, boolean_t); 713*0Sstevel@tonic-gate char utmpx_get_runlevel(void); 714*0Sstevel@tonic-gate void utmpx_set_runlevel(char, char, boolean_t); 715*0Sstevel@tonic-gate void utmpx_write_boottime(void); 716*0Sstevel@tonic-gate 717*0Sstevel@tonic-gate /* wait.c */ 718*0Sstevel@tonic-gate void wait_init(void); 719*0Sstevel@tonic-gate void wait_prefork(void); 720*0Sstevel@tonic-gate void wait_postfork(pid_t); 721*0Sstevel@tonic-gate int wait_register(pid_t, const char *, int, int); 722*0Sstevel@tonic-gate void *wait_thread(void *); 723*0Sstevel@tonic-gate 724*0Sstevel@tonic-gate /* proc.c */ 725*0Sstevel@tonic-gate ctid_t proc_get_ctid(); 726*0Sstevel@tonic-gate 727*0Sstevel@tonic-gate #ifdef __cplusplus 728*0Sstevel@tonic-gate } 729*0Sstevel@tonic-gate #endif 730*0Sstevel@tonic-gate 731*0Sstevel@tonic-gate #endif /* _STARTD_H */ 732