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