criu: rename current_ns_mask to root_ns_mask (v2)

Now we supports sub-mntns, so root_ns_mask sounds more correct than
current_ns_mask.

v2: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
zdtm/mountpoints: test nested mount namespaces

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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
Signed-off-by: Andrey Vagin <avagin@openvz.org>
zdtm: mark all mounts as private for one call

Signed-off-by: Andrey Vagin <avagin@openvz.org>
zdtm: reexec the mountpoints test in a target mntns

Otherwise it will have external files (from another namespace,
which isn't dumped).

Signed-off-by: Andrey Vagin <avagin@openvz.org>
files: save mnt_id on fd_param

Signed-off-by: Andrey Vagin <avagin@openvz.org>
files: save mnt_id for reg files

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
restore: close PROC_FD_OFF before calling sigreturn

mntns_collect_root() uses PROC_FD_OFF, so we need to close it.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: move dump_mnt_namespaces in mount.c

It will fill mntinfo list and this is internal logic of mount.c

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
resotre: collect mounts of current mntns

It's required for restoring in the current mntns.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: set nsid for each mount point

We want to look up mntns by mnt_id.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
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.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
irmap: mntns_collect_root in irmap_lookup

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: add a function to get a temporary root for mntns

On restore all mount namespaces are restored in the root mntns and
sub-namecpeaces are restored in temorary places.

This function allows to get paths to these places.

It will be used in open_remap_ghost(), because it's called in the root
task, when other tasks are not forked yet.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
mount: use per-ns list of mount-points in clean_mnt_ns and free_mnt_ns

We are going to dump nested mount namespaces, so we move the mountinfo
list on the namespace structure.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
check: collect mounts of the current mntns

They are used for collecting unix sockets

Signed-off-by: Andrey Vagin <avagin@openvz.org>