files: Don't call lseek on some restored files

Those opened for cwd, root, exe link and vma-s do not
care about the pos value.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Parse /proc/self/maps for self mappings

On restore we only need to know currnet task mappings' start and end
to find where to put the restorer blob. And since the smaps file in
/proc/pid is up to 3 times slower, than the maps one, it makes
perfect sense just to parse the latter one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
vma: Don't lookup file_desc for vma twice

We do it first -- on collect, second -- on restore. The
2nd lookup is excessive, we can put fd pointer on vm_area
at lookup and reuse one later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fifo: Don't lookup reg path twice

Same for previous patch with vmas -- we do it on collect and
on real open. Just put the pointer on fifo_info structure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files-reg: Sanitize open_xxx routines a bit

After previous fixes we can merge and move a couple
of them for easier reading.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Add comment to open_path routine

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make install: guess LIBDIR

For x86_64, LIBDIR can be tricky to find out. Nevertheless, this
works for at least RedHat/CentOS/Fedora, SLES/openSUSE, Debian/Ubuntu
and Gentoo. So, while it can guess LIBDIR wrong, this is still
a good approximation for those installing criu from source.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
ptrace: include config.h in ptrace.h

CONFIG_HAS_PEEKSIGINFO_ARGS is used there.

Cc: Christopher Covington <cov@codeaurora.org>
Reported-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
page-xfer: add proper initialization and deletion of xfer->parent

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Makefile: add soname to libcriu.so

Using a soname makes it easy for applications to
detect if the ABI of libcriu.so has changed.
It still creates libcriu.so as before in lib. During
'make install' additional links are created:

 libcriu.so -> libcriu.so.1.0
 libcriu.so.1 -> libcriu.so.1.0

Signed-off-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-service.c: rm extra error messages

setup_opts_from_req() prints an error message, so there's no need
for its caller to print another one.

While at it, simplify/unify error checking, treating any
non-zero value as an error.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
proto: Align members and numbers

We're aligning members and number in protobuf
files from the very beginning for readability
sake. So fix up newer ones which were not.

Also use /* */ comments, not //.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
deduplication: add \n to debug message

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
deduplication: remove double space

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>