2 * systest.c -- Test code for nooks system calls
4 * Copyright (C) 2002 Mike Swift
6 * The source code in this file can be freely used, adapted,
7 * and redistributed in source or binary form, so long as an
8 * acknowledgment appears in derived source files.
9 * No warranty is attached;
10 * we cannot take responsibility for errors or fitness for use.
14 #include <sys/types.h>
18 #include <asm/unistd.h>
23 #define swifi_inject_fault sys_inject_fault
25 #include "swifi-user.h"
30 _syscall6(long, swifi_inject_fault
,
32 unsigned long, faultType
,
33 unsigned long, randSeed
,
34 unsigned long, numFaults
,
36 unsigned long, do_inject
);
40 main(int argc
, char * argv
[])
42 char * module_name
= NULL
;
46 unsigned long arg
= 0;
47 unsigned long seed
= 157;
48 swifi_result_t
* res
= NULL
;
54 for (i
= 1; i
< argc
; i
++ ) {
55 if (strcmp(argv
[i
], "-f") == 0) {
59 module_name
= victim_exe
= argv
[++i
];
60 sscanf(argv
[++i
],"%u", &victim_pid
);
61 sscanf(argv
[++i
],"%u", &cmd
);
62 sscanf(argv
[++i
],"%lu", &arg
);
63 sscanf(argv
[++i
],"%lu", &seed
);
65 printf("Unknown command %s\n", argv
[i
]);
70 res
= malloc(arg
* sizeof(swifi_result_t
));
72 printf("Out of memory\n");
76 memset(res
, 0, sizeof(res
));
79 // Find out where the faults will be injected
82 result
= swifi_inject_fault(module_name
,
84 seed
, /* random seed */
87 0); /* don't inject now */
89 for (i
= 0; (i
< arg
) && (res
[i
].address
!= 0) ; i
++) {
90 printf("Changed 0x%lx from 0x%lx to 0x%lx\n",
101 result
= swifi_inject_fault(module_name
,
102 cmd
, /* fault type */
103 seed
, /* random seed */
106 1); /* do inject now */
108 printf("swifi_inject_fault returned %ld (%d)\n", result
,errno
);
119 printf("Usage: %s -f module_name pid fault-type fault-count seed\n", argv
[0]);