util-fd: print errors from send_fds

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
namespaces: Use long value to check for UINT_MAX

We have a condition

	BUG_ON(kid > UINT_MAX);

but kid is unsigned int so it's never bigger than UINT_MAX,
use unsigned long instead.

CID 1042296

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: Make sure open successed

Opening /dev/null may fail, check for ret code.

CID 1168167

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasie-syscall: Use close_safe to escape calling close on negative fd

CID 1042293

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: close all desriptors only for the root task

For all other tasks only unsed service descriptors will be closed.

This change allows to have file descriptors, which may be used for
restoring namespaces. All non-server descriptors must be closed before
restoring files.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
proc_parse: parse fdinfo to get pos and flags

We are going to parse fdinfo for getting mnt_id,
so we can take there pos and flags and don't call
fcntl and lseek for that.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
proc_parse: parse mnt_id from /proc/PID/fdinfo/FD

It will be used for restoring files from proper mounts.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
test
-g
mount: add EOL to the error message
mount: cut a common part of sources for bind-mounts
mount: dump and restore bind-mounts of the root mount

The root mount is an external mount and its source can be not '/'.
zdtm: check bind mounts of the root mount
devpts: open the ptmx device from the pts mount

Actually we need to open a ptmx device from a proper mount of devpts.
But currently we hard code the path to ptmx as /dev/ptmx. This patch
changes it on /dev/pts/ptmx.
zdtm: mount devpts with the newinstance flag
zdtm.sh: don't check path to ptmx

CRIU use a predefined path to open ptmx

-101 -> /dev/ptmx
+101 -> /dev/pts/ptmx
jenkins: add script for checking pre-dump
mount: close old descriptor in mntns_collect_root
mounts: initialize root before dumping mount namespace

Currently it's initialized for the root mount namespace, but we are
going to dump nested mount namespaces.

It's used in open_mountpoint(), which is used in dump_tmpfs() and in
other callbacks.
mounts: allow to customize root path for cr_pivot_root (v2)

We are going to restore nested mount namespaces and we will need to
change root for each of them.

v2: don't call chdir in a second time, because a path may be relative