2 * V3 Selective System Call Exiting Control
3 * (c) Kyle C. Hale, 2012
10 #include <sys/ioctl.h>
16 #include "iface-syscall.h"
20 #define SYSCALL_MAX 256
22 static void usage (char * argv[]) {
23 v3_usage("<vm device> <syscall_nr> <on|off|status>\n");
26 int main (int argc, char * argv[]) {
30 struct v3_syscall_cmd syscall_cmd;
32 if (argc < 4 || argc > 4) {
33 fprintf(stderr, "Invalid number of arguments.\n");
38 syscall_nr = strtol(argv[2], NULL, 0);
40 if (strncmp(argv[3], "on", CMD_MAX) == 0) {
41 syscall_cmd.cmd = SYSCALL_ON;
42 } else if (strncmp(argv[3], "off", CMD_MAX) == 0) {
43 syscall_cmd.cmd = SYSCALL_OFF;
44 } else if (strncmp(argv[3], "status", CMD_MAX) == 0) {
45 syscall_cmd.cmd = SYSCALL_STAT;
47 fprintf(stderr, "Invalid command.\n");
51 if (syscall_nr < 0 || syscall_nr > SYSCALL_MAX) {
52 fprintf(stderr, "Invalid syscall number.\n");
56 syscall_cmd.syscall_nr = syscall_nr;
58 ret = v3_vm_ioctl(vm_dev, V3_VM_SYSCALL_CTRL, &syscall_cmd);
61 fprintf(stderr, "Error with syscall control\n");
65 if (syscall_cmd.cmd == SYSCALL_STAT) {
66 if (ret == SYSCALL_ON)
67 printf("Selective exiting for syscall #%d is currently ON\n", syscall_cmd.syscall_nr);
68 else if (ret == SYSCALL_OFF)
69 printf("Selective exiting for syscall #%d is currently OFF\n", syscall_cmd.syscall_nr);
70 } else if (syscall_cmd.cmd == SYSCALL_ON) {
71 printf("Selective exiting for syscall #%d ACTIVATED\n", syscall_cmd.syscall_nr);
72 } else if (syscall_cmd.cmd == SYSCALL_OFF) {
73 printf("Selective exiting for syscall #%d DEACTIVATED\n", syscall_cmd.syscall_nr);