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
19 const struct syscalltable
*syscalls
;
21 unsigned int max_nr_syscalls
;
23 void activate_syscall(unsigned int calln
)
25 activate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
28 void deactivate_syscall(unsigned int calln
)
30 deactivate_syscall_in_table(calln
, &shm
->nr_active_syscalls
, syscalls
, shm
->active_syscalls
);
33 void toggle_syscall_n(int calln
, bool state
, const char *arg
, const char *arg_name
)
35 struct syscallentry
*entry
= syscalls
[calln
].entry
;
38 outputerr("No idea what syscall (%s) is.\n", arg
);
42 validate_specific_syscall(syscalls
, calln
);
45 entry
->flags
|= ACTIVE
;
46 activate_syscall(calln
);
48 entry
->flags
|= TO_BE_DEACTIVATED
;
51 output(0, "Marking syscall %s (%d) as to be %sabled.\n",
53 state
? "en" : "dis");
57 void enable_random_syscalls_uniarch(void)
60 struct syscallentry
*entry
;
63 call
= rand() % max_nr_syscalls
;
64 entry
= syscalls
[call
].entry
;
66 if (validate_specific_syscall_silent(syscalls
, call
) == FALSE
)
70 if (is_syscall_net_related(syscalls
, call
) == FALSE
)
73 /* if we've set this to be disabled, don't enable it! */
74 if (entry
->flags
& TO_BE_DEACTIVATED
)
77 toggle_syscall_n(call
, TRUE
, entry
->name
, entry
->name
);
80 void disable_non_net_syscalls_uniarch(void)
85 struct syscallentry
*entry
;
87 entry
= syscalls
[i
].entry
;
89 if (validate_specific_syscall_silent(syscalls
, i
) == FALSE
)
92 if (entry
->flags
& ACTIVE
) {
93 if (is_syscall_net_related(syscalls
, i
) == FALSE
)
94 toggle_syscall_n(i
, FALSE
, entry
->name
, entry
->name
);
99 int setup_syscall_group_uniarch(unsigned int group
)
103 for_each_syscall(i
) {
104 if (syscalls
[i
].entry
->group
== group
)
108 if (shm
->nr_active_syscalls
== 0) {
109 outputstd("No syscalls found in group\n");
112 outputstd("Found %d syscalls in group\n", shm
->nr_active_syscalls
);
118 void mark_all_syscalls_active_uniarch(void)
122 for_each_syscall(i
) {
123 syscalls
[i
].entry
->flags
|= ACTIVE
;
128 void init_syscalls_uniarch(void)
132 for_each_syscall(i
) {
133 struct syscallentry
*entry
;
135 entry
= syscalls
[i
].entry
;
136 if (entry
->flags
& ACTIVE
)
142 void deactivate_disabled_syscalls_uniarch(void)
144 struct syscallentry
*entry
;
147 for_each_syscall(i
) {
148 entry
= syscalls
[i
].entry
;
149 if (entry
->flags
& TO_BE_DEACTIVATED
) {
150 entry
->flags
&= ~(ACTIVE
|TO_BE_DEACTIVATED
);
151 deactivate_syscall(i
);
152 output(0, "Marked syscall %s (%d) as deactivated.\n",
153 entry
->name
, entry
->number
);
158 void dump_syscall_tables_uniarch(void)
162 outputstd("syscalls: %d\n", max_nr_syscalls
);
164 for_each_syscall(i
) {
165 struct syscallentry
*entry
;
167 entry
= syscalls
[i
].entry
;
168 outputstd("entrypoint %d %s : ", entry
->number
, entry
->name
);
169 show_state(entry
->flags
& ACTIVE
);
170 if (entry
->flags
& AVOID_SYSCALL
)
176 void display_enabled_syscalls_uniarch(void)
180 for_each_syscall(i
) {
181 struct syscallentry
*entry
;
183 entry
= syscalls
[i
].entry
;
185 if (entry
->flags
& ACTIVE
)
186 output(0, "syscall %d:%s enabled.\n", i
, entry
->name
);