mount: read information about all mount namespaces

read_mnt_ns_img() is splited on two parts. The first part enumirates all
namespaces and call the second part, which read a proper image file.
mounts: 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
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
ns: clean up dump_namespaces
files: save mnt_id on fd_param
files: save mnt_id for reg files
files-ids: generate id-s accoding with mnt_id, st->st_dev and st->st_ino

One device can be mounted a few times, so files are identical only,
if they have the same mnt_id.
mount: return descriptor from mntns_collect_root

We are going to support nested mount namespaces, so files can be opened
from more than one namespace and a root must be collect for each file.
mount: save mount tree for each namespace

We are going to support nested mount namespaces and each NS has own
tree. The mount tree is used for checking that a file is reachable.
mount: move dump_mnt_namespaces in mount.c

It will fill mntinfo list and this is internal logic of mount.c
mount: separate collect_mnt_ns from dump_mnt_ns

We are going to support nested mntns, so the global mntinfo_tree
variable are useless and information about tree should be connected
to a proper namespace.

But when we don't dump mntns, we need to collect mounts for the current
mntns.
resotre: collect mounts of current mntns

It's required for restoring in the current mntns.
mount: __lookup_mnt_id returns the first mi if mnt_id == -1

Kernels before 3.15 doesn't show mnt_id in /proc/PID/fdinfo/X.
When processes are restored in a current mntns, we have only one root,
so here isn't matter which mount will be returned.
mount: set nsid for each mount point

We want to look up mntns by mnt_id.
mounts: mntns_collect_root in __open_mountpoint

We are going to support nested mount namespaces,
file descriptors can be from different namespaces,
so a namespace root must be updated for each of them.
irmap: mntns_collect_root in irmap_lookup