mount: add EOL to the error message
servicefd: add a service fd for current root

It's already used for dumping files and it will be used for restoring,
so it should be service fd to avoid intersection with restored
descriptors.
mount: save relative path in mi->mountpoint

"relative path" is absolute path with dot at the beginning.

We already use relative paths on restore. In this patch we add "."
on dump too. It's convinient, because we needed to add dot each time
when we want to access this mount point.
Before this patch we had to created a temporary copy.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: open_mountpoint returns a file descriptro

Only one function use DIR, so I don't see reason to return it
mount: fix comparison of stat.st_dev and mount_info->s_dev (v2)

st_dev and s_dev have different formats.
st_dev is (MAJOR(dev) << 8) | MINOR(dev)
s_dev is (MAJOR(dev) << 20) | MINOR(dev)

so we need to convert one of them

v2: use kdev_to_odev
mount: open_mount uses __open_mountpoint instead of own logic

Now we have two funсtions which do mostly the same, so this patch merges
them.
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
restore: add mount id-s in the ns_ids list (v4)

Currently ns_ids is filled only on dump. Now we are going to restore
nested mount namespaces, so we need to know who share name spaces.

v2: merge the patch "namespace: add a function to search an ns_id
item by id" into this one.
v3: add prefix rst_ to add_ns_id
v4: look up namespace by two values -- type AND ID
mounts: mark local root-s in the list of mount points (v2)

We are going to dump nested mount namespaces. All sub-namespaces will be
restored as sub-mounts in the root mount namespace. So mi->mountpoint
will be not '/' even if a mount is root for its mntns.

v2: s/is_root/is_ns_root/
mounts: connect sub-root to the main root

A sub-mount namespace is restored as sub-tree of the root mntns, so
the parent of sub-mntns root is the root of the root mntns.
mounts: share one root for all namespaces

Currently we support nested mount namespaces, only if all of them have
the same root.

crtools doesn't mount root, so it should be bind-mounted for all
namespaces.
mounts: prepare to create a temporary directory for restoring non-root mntns (v2)

All non-root namespaces will be restored as sub-trees of the root tree.

This patch adds helpers to create a temporary directory and mount tmpfs
in it, then create directories for each non-root mount namespace.

tmpfs is quite useful here to simplify destroying this construction,
we don't need to unmount each namespace separately.

v2: add a comment why MNT_DETACH is not dangerous here
mounts: create a temporary directory for restoring non-root mntns

All non-root namespaces will be restored as sub-trees of the root tree.

This patch creates a temporary directory and mount tmpfs in it, then
create directories for each non-root mount namespace.

tmpfs is quite useful here to simplify destroying this construction,
we don't need to unmount each namespace separately.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: restore nested mount namespaces (v2)

Known issue:
* currently only namespaces with the same root is supported
* nested namespaces can be dumped and restored only if the root task
  has own mount namespace.

All nested namespaces are restored in a root namespace in temporary
directories. All mount points restored in one tree and then they are
divided into namesaces.
The task with minimal pid for each namespaces unshared mntns and
then it makes pivot_root in a proper temporary directory. All other
tasks makes setns to enter into a mount namespace of the task with
minimal pid.

v2: clean up

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: allow to dump and restore nested mount namespaces (v3)

v2: another attempt to write readable code:)
v3: clean up
criu: rename current_ns_mask to root_ns_mask

Now we supports sub-mntns, so root_ns_mask sounds more correct than
current_ns_mask.
zdtm/mountpoints: test nested mount namespaces
namespaces: dump mount namespaces before tasks (v2)

because we want to check, that all files are reachable.
For that we need to collect all mounts from all namespaces.

v2: dump mntns separately