summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fail.c
diff options
context:
space:
mode:
authormdf <mdf@FreeBSD.org>2010-12-21 16:29:58 +0000
committermdf <mdf@FreeBSD.org>2010-12-21 16:29:58 +0000
commit9d7bd11478a2bc79badff60c9d39e14e86c24d8f (patch)
tree3503bc0d05c80816c53a46ad78be7c079f4d2675 /sys/kern/kern_fail.c
parentdedc1118c91f6a1864ac68ba3afb27deff664992 (diff)
downloadFreeBSD-src-9d7bd11478a2bc79badff60c9d39e14e86c24d8f.zip
FreeBSD-src-9d7bd11478a2bc79badff60c9d39e14e86c24d8f.tar.gz
Move the fail_point_entry definition from fail.h to kern_fail.c, which
allows putting the enumeration constants of fail point types with the text string that matches them. MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_fail.c')
-rw-r--r--sys/kern/kern_fail.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/sys/kern/kern_fail.c b/sys/kern/kern_fail.c
index d7601a9..965219e 100644
--- a/sys/kern/kern_fail.c
+++ b/sys/kern/kern_fail.c
@@ -76,6 +76,43 @@ MTX_SYSINIT(g_fp_mtx, &g_fp_mtx, "fail point mtx", MTX_DEF);
#define FP_LOCK() mtx_lock(&g_fp_mtx)
#define FP_UNLOCK() mtx_unlock(&g_fp_mtx)
+/**
+ * Failpoint types.
+ * Don't change these without changing fail_type_strings in fail.c.
+ * @ingroup failpoint_private
+ */
+enum fail_point_t {
+ FAIL_POINT_OFF, /**< don't fail */
+ FAIL_POINT_PANIC, /**< panic */
+ FAIL_POINT_RETURN, /**< return an errorcode */
+ FAIL_POINT_BREAK, /**< break into the debugger */
+ FAIL_POINT_PRINT, /**< print a message */
+ FAIL_POINT_SLEEP, /**< sleep for some msecs */
+ FAIL_POINT_INVALID, /**< placeholder */
+};
+
+static const char *fail_type_strings[] = {
+ "off",
+ "panic",
+ "return",
+ "break",
+ "print",
+ "sleep",
+};
+
+/**
+ * Internal structure tracking a single term of a complete failpoint.
+ * @ingroup failpoint_private
+ */
+struct fail_point_entry {
+ enum fail_point_t fe_type; /**< type of entry */
+ int fe_arg; /**< argument to type (e.g. return value) */
+ int fe_prob; /**< likelihood of firing in millionths */
+ int fe_count; /**< number of times to fire, 0 means always */
+
+ TAILQ_ENTRY(fail_point_entry) fe_entries; /**< next entry in fail point */
+};
+
static inline void
fail_point_sleep(struct fail_point *fp, struct fail_point_entry *ent,
int msecs, enum fail_point_return_code *pret)
@@ -102,15 +139,6 @@ enum {
PROB_DIGITS = 6, /* number of zero's in above number */
};
-static const char *fail_type_strings[] = {
- "off",
- "panic",
- "return",
- "break",
- "print",
- "sleep",
-};
-
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 *);
OpenPOWER on IntegriCloud