FreeBSD kernel kern code
|
![]() |
Files | |
file | kern_fail.c |
Data Structures | |
struct | fail_point_entry |
Macros | |
#define | fp_free(ptr) free(ptr, M_FAIL_POINT) |
#define | fp_malloc(size, flags) malloc((size), M_FAIL_POINT, (flags)) |
#define | FP_LOCK() mtx_lock(&g_fp_mtx) |
#define | FP_UNLOCK() mtx_unlock(&g_fp_mtx) |
#define | MAX_FAIL_POINT_BUF 1023 |
Enumerations | |
enum | fail_point_t { FAIL_POINT_OFF, FAIL_POINT_PANIC, FAIL_POINT_RETURN, FAIL_POINT_BREAK, FAIL_POINT_PRINT, FAIL_POINT_SLEEP, FAIL_POINT_NUMTYPES } |
enum | { PROB_MAX = 1000000, PROB_DIGITS = 6 } |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_FAIL_POINT,"Fail Points","fail points system") |
MTX_SYSINIT (g_fp_mtx,&g_fp_mtx,"fail point mtx", MTX_DEF) | |
static void | fail_point_sleep (struct fail_point *fp, struct fail_point_entry *ent, int msecs, enum fail_point_return_code *pret) |
static char * | parse_fail_point (struct fail_point_entries *, char *) |
static char * | parse_term (struct fail_point_entries *, char *) |
static char * | parse_number (int *out_units, int *out_decimal, char *) |
static char * | parse_type (struct fail_point_entry *, char *) |
static void | free_entry (struct fail_point_entries *, struct fail_point_entry *) |
static void | clear_entries (struct fail_point_entries *) |
enum fail_point_return_code | fail_point_eval_nontrivial (struct fail_point *fp, int *return_value) |
static void | fail_point_get (struct fail_point *fp, struct sbuf *sb) |
static int | fail_point_set (struct fail_point *fp, char *buf) |
int | fail_point_sysctl (SYSCTL_HANDLER_ARGS) |
SYSCTL_NODE (_debug, OID_AUTO, fail_point, CTLFLAG_RW, 0,"fail points") | |
Variables | |
static struct mtx | g_fp_mtx |
const char * name | |
int nmlen | |
struct { | |
const char * name | |
int nmlen | |
} | fail_type_strings [] |
enum fail_point_t | fail_point_entry::fe_type |
int | fail_point_entry::fe_arg |
int | fail_point_entry::fe_prob |
int | fail_point_entry::fe_count |
pid_t | fail_point_entry::fe_pid |
Private implementations for the actual failpoint code.
#define fp_free | ( | ptr | ) | free(ptr, M_FAIL_POINT) |
Definition at line 73 of file kern_fail.c.
Referenced by clear_entries(), fail_point_destroy(), fail_point_sysctl(), and free_entry().
#define FP_LOCK | ( | ) | mtx_lock(&g_fp_mtx) |
Definition at line 78 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), and fail_point_set().
#define fp_malloc | ( | size, | |
flags | |||
) | malloc((size), M_FAIL_POINT, (flags)) |
Definition at line 74 of file kern_fail.c.
Referenced by fail_point_init(), fail_point_sysctl(), and parse_term().
#define FP_UNLOCK | ( | ) | mtx_unlock(&g_fp_mtx) |
Definition at line 79 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), and fail_point_set().
#define MAX_FAIL_POINT_BUF 1023 |
Definition at line 383 of file kern_fail.c.
Referenced by fail_point_sysctl().
anonymous enum |
Defines stating the equivalent of probablilty one (100%)
Enumerator | |
---|---|
PROB_MAX | |
PROB_DIGITS |
Definition at line 143 of file kern_fail.c.
enum fail_point_t |
Failpoint types. Don't change these without changing fail_type_strings in fail.c.
Definition at line 86 of file kern_fail.c.
__FBSDID | ( | "$BSDSUniX$" | ) |
|
static |
Internal helper function to clear out all failpoint terms for a single failpoint.
Definition at line 601 of file kern_fail.c.
References fp_free.
Referenced by fail_point_destroy(), and fail_point_set().
enum fail_point_return_code fail_point_eval_nontrivial | ( | struct fail_point * | fp, |
int * | return_value | ||
) |
This does the real work of evaluating a fail point. If the fail point tells us to return a value, this function returns 1 and fills in 'return_value' (return_value is allowed to be null). If the fail point tells us to panic, we never return. Otherwise we just return 0 after doing some work, which means "keep going".
Definition at line 217 of file kern_fail.c.
References FAIL_POINT_BREAK, FAIL_POINT_OFF, FAIL_POINT_PANIC, FAIL_POINT_PRINT, FAIL_POINT_RETURN, FAIL_POINT_SLEEP, fail_point_sleep(), fail_point_entry::fe_arg, fail_point_entry::fe_count, fail_point_entry::fe_pid, fail_point_entry::fe_prob, fail_point_entry::fe_type, FP_LOCK, FP_UNLOCK, free_entry(), panic(), printf(), and PROB_MAX.
|
static |
Translate internal fail_point structure into human-readable text.
Definition at line 295 of file kern_fail.c.
References fail_type_strings, fail_point_entry::fe_arg, fail_point_entry::fe_count, fail_point_entry::fe_pid, fail_point_entry::fe_prob, fail_point_entry::fe_type, FP_LOCK, FP_UNLOCK, PROB_DIGITS, PROB_MAX, and sbuf_printf().
Referenced by fail_point_sysctl().
|
static |
Set an internal fail_point structure from a human-readable failpoint string in a lock-safe manner.
Definition at line 337 of file kern_fail.c.
References clear_entries(), FAIL_POINT_OFF, fail_point_entry::fe_prob, fail_point_entry::fe_type, FP_LOCK, FP_UNLOCK, free_entry(), and parse_fail_point().
Referenced by fail_point_sysctl().
|
inlinestatic |
Definition at line 123 of file kern_fail.c.
References g_fp_mtx, hz, and timeout().
Referenced by fail_point_eval_nontrivial().
int fail_point_sysctl | ( | SYSCTL_HANDLER_ARGS | ) |
Handle kernel failpoint set/get.
Definition at line 389 of file kern_fail.c.
References buf, fail_point_get(), fail_point_set(), fp_free, fp_malloc, MAX_FAIL_POINT_BUF, sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), sbuf_new(), and sbuf_trim().
|
static |
Internal helper function to free an individual failpoint term.
Definition at line 590 of file kern_fail.c.
References fp_free.
Referenced by fail_point_eval_nontrivial(), and fail_point_set().
|
static |
MTX_SYSINIT | ( | g_fp_mtx | , |
& | g_fp_mtx, | ||
"fail point mtx" | , | ||
MTX_DEF | |||
) |
|
static |
Internal helper function to translate a human-readable failpoint string into a internally-parsable fail_point structure.
Definition at line 431 of file kern_fail.c.
References parse_term().
Referenced by fail_point_set().
|
static |
Internal helper function to parse a numeric for a failpoint term.
Definition at line 528 of file kern_fail.c.
References PROB_DIGITS.
Referenced by parse_term().
|
static |
Internal helper function to parse an individual term from a failpoint.
Definition at line 453 of file kern_fail.c.
References fail_point_entry::fe_arg, fail_point_entry::fe_count, fail_point_entry::fe_pid, fail_point_entry::fe_prob, fp_malloc, parse_number(), parse_type(), PID_STRING, and PROB_MAX.
Referenced by parse_fail_point().
|
static |
Internal helper function to parse an individual type for a failpoint term.
Definition at line 571 of file kern_fail.c.
References FAIL_POINT_NUMTYPES, FAIL_POINT_OFF, fail_type_strings, fail_point_entry::fe_type, name, and type.
Referenced by parse_term().
SYSCTL_NODE | ( | _debug | , |
OID_AUTO | , | ||
fail_point | , | ||
CTLFLAG_RW | , | ||
0 | , | ||
"fail points" | |||
) |
struct { ... } fail_type_strings[] |
Referenced by fail_point_get(), and parse_type().
int fail_point_entry::fe_arg |
argument to type (e.g. return value)
Definition at line 115 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), and parse_term().
int fail_point_entry::fe_count |
number of times to fire, 0 means always
Definition at line 117 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), and parse_term().
pid_t fail_point_entry::fe_pid |
only fail for this process
Definition at line 118 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), and parse_term().
int fail_point_entry::fe_prob |
likelihood of firing in millionths
Definition at line 116 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), fail_point_set(), and parse_term().
enum fail_point_t fail_point_entry::fe_type |
type of entry
Definition at line 114 of file kern_fail.c.
Referenced by fail_point_eval_nontrivial(), fail_point_get(), fail_point_set(), and parse_type().
|
static |
Definition at line 76 of file kern_fail.c.
Referenced by fail_point_sleep().
const char * name |
Definition at line 97 of file kern_fail.c.
Referenced by accept1(), coredump(), device_print_prettyname(), fail_point_init(), kern_getsockopt(), kern_jail_get(), kern_jail_set(), kern_setsockopt(), kmeminit(), lock_init(), mount_arg(), mount_argf(), parse_dir_ask(), parse_mountroot_options(), parse_type(), pmc_soft_namecleanup(), prison_name(), stack_print_ddb(), sys_kenv(), sys_modfind(), sys_modstat(), sys_thr_set_name(), sysctl_devices(), sysctl_kern_proc(), sysctl_kern_proc_args(), sysctl_kern_proc_auxv(), sysctl_kern_proc_env(), sysctl_kern_proc_filedesc(), sysctl_kern_proc_sv_name(), sysctl_kern_proc_vmmap(), sysctl_rman(), TAILQ_HEAD(), terminal_maketty(), tty_makedev(), ttyconsdev_select(), and vfs_sysctl().
const { ... } name |
Definition at line 97 of file kern_fail.c.
int nmlen |
Definition at line 98 of file kern_fail.c.
int { ... } nmlen |
Definition at line 98 of file kern_fail.c.