diff --git a/unreliablefs_errinj.c b/unreliablefs_errinj.c index a71c63d..a069f4d 100644 --- a/unreliablefs_errinj.c +++ b/unreliablefs_errinj.c @@ -15,6 +15,37 @@ #include "unreliablefs.h" #include "unreliablefs_errinj.h" +const char *errinj_name[] = +{ + "errinj_errno", + "errinj_kill_caller", + "errinj_noop", + "errinj_slowdown", +}; + +typedef enum { + ERRINJ_ERRNO, + ERRINJ_KILL_CALLER, + ERRINJ_NOOP, + ERRINJ_SLOWDOWN, +} errinj_type; + +typedef struct errinj_conf errinj_conf; + +struct errinj_conf { + char *err_injection_name; + char *op_regexp; + char *path_regexp; + char *errno_regexp; + unsigned int probability; + unsigned int duration; + errinj_type type; + + TAILQ_ENTRY(errinj_conf) entries; +}; + +TAILQ_HEAD(err_inj_q, errinj_conf); + static int rand_range(int, int); int error_inject(const char* path, fuse_op operation); diff --git a/unreliablefs_errinj.h b/unreliablefs_errinj.h index 2dcc775..299d502 100644 --- a/unreliablefs_errinj.h +++ b/unreliablefs_errinj.h @@ -31,35 +31,4 @@ int conf_option_handler(void* cfg, const char* section, const char* name, const char* value); int is_regex_matched(const char *regex, const char *string); -const char *errinj_name[] = -{ - "errinj_errno", - "errinj_kill_caller", - "errinj_noop", - "errinj_slowdown", -}; - -typedef enum { - ERRINJ_ERRNO, - ERRINJ_KILL_CALLER, - ERRINJ_NOOP, - ERRINJ_SLOWDOWN, -} errinj_type; - -typedef struct errinj_conf errinj_conf; - -struct errinj_conf { - char *err_injection_name; - char *op_regexp; - char *path_regexp; - char *errno_regexp; - unsigned int probability; - unsigned int duration; - errinj_type type; - - TAILQ_ENTRY(errinj_conf) entries; -}; - -TAILQ_HEAD(err_inj_q, errinj_conf); - #endif /* ERRINJ_HH */ diff --git a/unreliablefs_ops.c b/unreliablefs_ops.c index 8c628a9..f9d48d5 100644 --- a/unreliablefs_ops.c +++ b/unreliablefs_ops.c @@ -16,9 +16,8 @@ #define _XOPEN_SOURCE 700 #endif -#define ERRNO_NOOP -999 - #include "unreliablefs_ops.h" +#include "unreliablefs_errinj.h" const char *fuse_op_name[] = { "getattr",