2 * Functions for handling the system call tables.
3 * These functions are only used by architectures that have either 32 or 64 bit syscalls, but not both.
11 #include "trinity.h" // ARRAY_SIZE, alloc_shared
18 const struct syscalltable
*syscalls
;
20 unsigned int max_nr_syscalls
;
22 void activate_syscall(unsigned int calln
)
24 activate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
27 void deactivate_syscall(unsigned int calln
)
29 deactivate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
32 void toggle_syscall_n(int calln
, bool state
, const char *arg
, const char *arg_name
)
35 outputerr("No idea what syscall (%s) is.\n", arg
);
39 validate_specific_syscall(syscalls
, calln
);
42 syscalls
[calln
].entry
->flags
|= ACTIVE
;
43 activate_syscall(calln
);
45 syscalls
[calln
].entry
->flags
|= TO_BE_DEACTIVATED
;
48 output(0, "Marking syscall %s (%d) as to be %sabled.\n",
50 state
? "en" : "dis");
54 void enable_random_syscalls_uniarch(void)
59 call
= rand() % max_nr_syscalls
;
61 if (validate_specific_syscall_silent(syscalls
, call
) == FALSE
)
65 if (is_syscall_net_related(syscalls
, call
) == FALSE
)
68 /* if we've set this to be disabled, don't enable it! */
69 if (syscalls
[call
].entry
->flags
& TO_BE_DEACTIVATED
)
72 toggle_syscall_n(call
, FALSE
, syscalls
[call
].entry
->name
, syscalls
[call
].entry
->name
);
75 void disable_non_net_syscalls_uniarch(void)
80 if (validate_specific_syscall_silent(syscalls
, i
) == FALSE
)
83 if (syscalls
[i
].entry
->flags
& ACTIVE
) {
84 if (is_syscall_net_related(syscalls
, i
) == FALSE
) {
85 toggle_syscall_n(i
, FALSE
, syscalls
[i
].entry
->name
, syscalls
[i
].entry
->name
);
91 int setup_syscall_group_uniarch(unsigned int group
)
96 if (syscalls
[i
].entry
->group
== group
)
100 if (shm
->nr_active_syscalls
== 0) {
101 outputstd("No syscalls found in group\n");
104 outputstd("Found %d syscalls in group\n", shm
->nr_active_syscalls
);
110 void mark_all_syscalls_active_uniarch(void)
114 for_each_syscall(i
) {
115 syscalls
[i
].entry
->flags
|= ACTIVE
;
120 void init_syscalls_uniarch(void)
124 for_each_syscall(i
) {
125 if (syscalls
[i
].entry
->flags
& ACTIVE
)
126 if (syscalls
[i
].entry
->init
)
127 syscalls
[i
].entry
->init();