2 * V3 Selective System Call Exiting Control
3 * (c) Kyle C. Hale, 2012
10 #include <sys/ioctl.h>
16 #include "iface-syscall.h"
19 #define SYSCALL_MAX 256
21 static void usage () {
22 fprintf(stderr, "\nUsage: v3_syscall <vm device> <syscall_nr> <on|off|status>\n");
27 int main (int argc, char * argv[]) {
29 int vm_fd, ret, syscall_nr;
31 struct v3_syscall_cmd syscall_cmd;
33 if (argc < 4 || argc > 4) {
34 fprintf(stderr, "Invalid number of arguments.\n");
39 syscall_nr = strtol(argv[2], NULL, 0);
41 if (strncmp(argv[3], "on", CMD_MAX) == 0) {
42 syscall_cmd.cmd = SYSCALL_ON;
43 } else if (strncmp(argv[3], "off", CMD_MAX) == 0) {
44 syscall_cmd.cmd = SYSCALL_OFF;
45 } else if (strncmp(argv[3], "status", CMD_MAX) == 0) {
46 syscall_cmd.cmd = SYSCALL_STAT;
48 fprintf(stderr, "Invalid command.\n");
52 if (syscall_nr < 0 || syscall_nr > SYSCALL_MAX) {
53 fprintf(stderr, "Invalid syscall number.\n");
57 syscall_cmd.syscall_nr = syscall_nr;
59 vm_fd = open(vm_dev, O_RDONLY);
62 fprintf(stderr, "Error opening VM device: %s\n", vm_dev);
66 ret = ioctl(vm_fd, V3_VM_SYSCALL_CTRL, &syscall_cmd);
69 fprintf(stderr, "Error with syscall control\n");
73 if (syscall_cmd.cmd == SYSCALL_STAT) {
74 if (ret == SYSCALL_ON)
75 printf("Selective exiting for syscall #%d is currently ON\n", syscall_cmd.syscall_nr);
76 else if (ret == SYSCALL_OFF)
77 printf("Selective exiting for syscall #%d is currently OFF\n", syscall_cmd.syscall_nr);
78 } else if (syscall_cmd.cmd == SYSCALL_ON) {
79 printf("Selective exiting for syscall #%d ACTIVATED\n", syscall_cmd.syscall_nr);
80 } else if (syscall_cmd.cmd == SYSCALL_OFF) {
81 printf("Selective exiting for syscall #%d DEACTIVATED\n", syscall_cmd.syscall_nr);