mount: detect the newinstance option for devpts (v2)

The devpts instance was mounted w/o the newinstance option if,
the device number is equal to the root /dev/pts.

I think this condition is strong enough to not mount devpts in a
temporary place.

v2: move the host.bla-bla-bla in kerndat.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr: collect short integer aliases in the single place

This patch moves the files arch/$ARCH/include/asm/int.h to
include/asm-generic/int.h and makes the types {u,s}{8,16,32}
be aliases of the fixed sized integer types [u]int{8,16,32}_t.

This makes it possible to use single set of integer typedefs
in all architectural ports.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sigframe: cast the pointer to the field ucontext::uc_sigmask to k_rtsigset_t

The type of the field ucontext::uc_sigmask isn't k_rtsigset_t
if the struct ucontext is imported from system headers
rather than provided by an architecture-specific header.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-dump: allocate dfds near the place where it's used

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
test
-g
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
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.
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

We are going to restore nested mount namespaces and we will need to
change root for each of them.
restore: add mount id-s in the ns_ids list (v3)

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
mounts: mark local root-s in the list of mount points

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.
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

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.

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