Commit a2063263 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Andrei Vagin

zdtm/vdso01: separate handlers calling traversal

Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 0f4b1220
......@@ -359,60 +359,58 @@ static int vdso_time_handler(void *func)
return 0;
}
int main(int argc, char *argv[])
static int call_handlers(struct vdso_symtable *symtable)
{
typedef int (handler_t)(void *func);
struct vdso_symtable symtable;
size_t i;
handler_t *handlers[VDSO_SYMBOL_MAX] = {
[VDSO_SYMBOL_CLOCK_GETTIME] = vdso_clock_gettime_handler,
[VDSO_SYMBOL_GETCPU] = vdso_getcpu_handler,
[VDSO_SYMBOL_GETTIMEOFDAY] = vdso_gettimeofday_handler,
[VDSO_SYMBOL_TIME] = vdso_time_handler,
};
size_t i;
test_init(argc, argv);
if (vdso_fill_self_symtable(&symtable)) {
pr_perror("Faied to parse vdso");
return -1;
}
for (i = 0; i < ARRAY_SIZE(symtable.symbols); i++) {
struct vdso_symbol *s = &symtable.symbols[i];
for (i = 0; i < ARRAY_SIZE(symtable->symbols); i++) {
struct vdso_symbol *s = &symtable->symbols[i];
handler_t *func;
if (vdso_symbol_empty(s) || i > ARRAY_SIZE(handlers))
continue;
func = handlers[i];
if (func((void *)(s->offset + symtable.vma_start))) {
if (func((void *)(s->offset + symtable->vma_start))) {
pr_perror("Handler error");
return -1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
struct vdso_symtable symtable;
test_init(argc, argv);
if (vdso_fill_self_symtable(&symtable)) {
pr_perror("Faied to parse vdso");
return -1;
}
if (call_handlers(&symtable))
return -1;
test_daemon();
test_waitsig();
/*
* After restore the vDSO must remain in old place.
*/
for (i = 0; i < ARRAY_SIZE(symtable.symbols); i++) {
struct vdso_symbol *s = &symtable.symbols[i];
handler_t *func;
if (vdso_symbol_empty(s) || i > ARRAY_SIZE(handlers))
continue;
func = handlers[i];
if (func((void *)(s->offset + symtable.vma_start))) {
fail("Handler error");
if (call_handlers(&symtable)) {
fail("Failed to call vdso handlers from symtable after C/R");
return -1;
}
}
pass();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment