Repository navigation
Expand file tree
/
Copy pathsystest.c
More file actions
67 lines (58 loc) · 1.41 KB
/
Copy pathsystest.c
File metadata and controls
67 lines (58 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* systest.c -- Test code for nooks system calls
*
* Copyright (C) 2002 Mike Swift
*
* The source code in this file can be freely used, adapted,
* and redistributed in source or binary form, so long as an
* acknowledgment appears in derived source files.
* No warranty is attached;
* we cannot take responsibility for errors or fitness for use.
*
*/
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "swifi.h"
#include "extra.h"
void
usage(char *name)
{
printf("Usage: %s -f module_name pid fault-type fault-count seed\n", name);
exit(EXIT_FAILURE);
}
int
main(int argc, char * argv[])
{
char * module_name = NULL;
int i;
unsigned int cmd = 0;
unsigned long arg = 0;
unsigned long seed = 157;
if (argc < 2) {
usage(argv[0]);
}
for (i = 1; i < argc; i++ ) {
if (strcmp(argv[i], "-f") == 0) {
if (argc <= i+5) {
usage(argv[0]);
}
module_name = victim_exe = argv[++i];
sscanf(argv[++i],"%u", &victim_pid);
sscanf(argv[++i],"%u", &cmd);
sscanf(argv[++i],"%lu", &arg);
sscanf(argv[++i],"%lu", &seed);
} else {
printf("Unknown command %s\n", argv[i]);
usage(argv[0]);
}
}
/* Do the injection. */
swifi_inject_fault(module_name,
cmd, /* fault type */
seed, /* random seed */
arg); /* numFaults */
return EXIT_SUCCESS;
}