commit - f923f0253af63c48b2b8df7d3da6727116b20076
commit + fb06980062f7ef0217ddcc10ae259adbabb14589
blob - 7279944faea1fd360a270e4a5296980a9b5f2e45
blob + d769300424c04d6460a3a50882e25ca1b0c9ec88
--- README.md
+++ README.md
- `errinj_noop` - replace file operation with no operation
(similar to [libeatmydata](https://github.com/stewartsmith/libeatmydata),
but applicable to any file operation).
+- `errinj_kill_caller` - send SIGKILL to a process that invoked file operation.
### Building
blob - a27f32bbc1825578e040a54c9326b06fea056b87
blob + 25907eff9806ff09b605e63f0dabe8d867074c4d
--- unreliablefs.conf.5
+++ unreliablefs.conf.5
.Bl -tag -width Ds
.It Cm errinj_noop
File operation replaced with no-op.
+.It Cm errinj_kill_caller
+Send SIGKILL signal to a process that invoked file operation.
.El
.Pp
The options are:
blob - ca7bc1fd4dd53ea18989ab28d6cbd9f2b3830f8d
blob + 498a4a9dbb1544935fb1cf4d1d3175405ac978a4
--- unreliablefs_errinj.c
+++ unreliablefs_errinj.c
#include <fuse.h>
#include <libgen.h> /* basename() and dirname() */
#include <regex.h>
+#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
#include <sys/queue.h>
#include "conf.h"
errinj_name[err->type], operation, path);
rc = 0;
break;
+ case ERRINJ_KILL_CALLER:
+ fprintf(stderr, "%s triggered on operation '%s', %s\n",
+ errinj_name[err->type], operation, path);
+ struct fuse_context *cxt = fuse_get_context();
+ if (cxt) {
+ int ret = kill(cxt->pid, DEFAULT_SIGNAL_NAME);
+ if (!ret) {
+ perror("kill");
+ }
+ }
+ free(cxt);
+ rc = 0;
+ break;
}
}
blob - 8f3a081777a733e4d6dd713f3d88eb1e31f5cc02
blob + 25be1b98e88fc0c533ed3afda86458e1fa137e1d
--- unreliablefs_errinj.h
+++ unreliablefs_errinj.h
#define MIN_PROBABLITY 0
#define MAX_PROBABLITY 100
+#define DEFAULT_SIGNAL_NAME SIGKILL
+
int error_inject(const char* path, char* operation);
struct err_inj_q *config_init(const char* conf_path);
void config_delete(struct err_inj_q *config);
const char *errinj_name[] =
{
"errinj_noop",
+ "errinj_kill_caller",
};
typedef enum {
ERRINJ_NOOP,
+ ERRINJ_KILL_CALLER,
} errinj_type;
typedef struct errinj_conf errinj_conf;