Commit e50235b6 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

compel: Routine to open proc files

Yet again -- CRIU has an optimized openat()-based engine that
is slightly faster for opening "/proc" files rather than plain
open(). The latter is provided by default by compel.

travis-ci: success for compel: Contrinue improving library
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent b0dfd996
...@@ -959,6 +959,21 @@ out: ...@@ -959,6 +959,21 @@ out:
return ret; return ret;
} }
static int simple_open_proc(int pid, int mode, const char *fmt, ...)
{
int l;
char path[128];
va_list args;
l = sprintf(path, "/proc/%d/", pid);
va_start(args, fmt);
vsnprintf(path + l, sizeof(path) - l, fmt, args);
va_end(args);
return open(path, mode);
}
struct parasite_ctl *compel_prepare(int pid) struct parasite_ctl *compel_prepare(int pid)
{ {
struct parasite_ctl *ctl; struct parasite_ctl *ctl;
...@@ -970,6 +985,7 @@ struct parasite_ctl *compel_prepare(int pid) ...@@ -970,6 +985,7 @@ struct parasite_ctl *compel_prepare(int pid)
ictx = &ctl->ictx; ictx = &ctl->ictx;
ictx->task_size = compel_task_size(); ictx->task_size = compel_task_size();
ictx->open_proc = simple_open_proc;
ictx->syscall_ip = find_executable_area(pid); ictx->syscall_ip = find_executable_area(pid);
if (ictx->syscall_ip == (unsigned long)MAP_FAILED) if (ictx->syscall_ip == (unsigned long)MAP_FAILED)
goto err; goto err;
......
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