mount: Reset mountinfos when mntns recreated

The list of mounts is used by inotify to restore a watch with open-by-handle. The problem
is that after the clean_mnt_ns is done the mntinfo list is no longer relevant.

Fix it by freeing the old one and initializing the new with the read-from-image stuff.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signalfd: Add protobuf descriptions

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signalfd: Add proc fdinfo parsing facility

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signalfd: Dumping and restoring

Only the fact of the fd presence, its flags and fown and the sigmask.
The sigpending state is tightly coupled with the task's sigpending
state which is not yet supported.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signalfd: Checking code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Signalfd testing

It's not in zdtm.sh yet, since kernel patch is not yet
committed. When kernel is updated, the zdtm.sh will be too.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Wire signalfd00 in

The kernel patch is in 3.5 branch, so we can make this test
run automatically.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pstee: fix memory corrupation

The pstree_item for helpers is allocated without rst_info.
Before this patch prepare_fd_pid was executed for such items and
touched rst_info.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: add an option for changing a root file system (v2)

The option is -r|--pivot-root and an argument is a path to new root.
A root task will make pivot_root. LXC CT does that, so we need that
for restoring.

v2: s/pivot-root/root/

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: prepare shared objects after initializing namespaces

On this stage crtools unlink old socket files, create ghost files and etc,
so we should be in a correct namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Don't pull opts through the stack

Revert and tune 9eda83b7. Andrey reminded me that we have
global instance of cr_options.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mount: Cleanup readlinkat calling

 - Use sizeof instead of PATH_MAX constant
 - Place EOS exactly after read data end

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files-reg: Drop redundant double semicolon

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
help: Add mnt and net options into the list

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
doc: Update -n option

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
socket_listen: interrupt a parent if a child exited

When a child exited, SIGCHLD is sent to parent,
if SIGCHLD has handler without SA_RESTART, the current
syscall will be interrupted.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: fix clean up in PIDNS

When processes are restored in PIDNS, the controll process (crtools)
don't know a real pid of processes, but it knows a pid of init.

crtools can kill init and all other processes will be killed too.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
namespace: return -1 if one of ns can't be initilized

[xemul: Added explicit braces into ifs]

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: mount_proc return a result instead of exit

In addition it fixes error handling.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: consolidate restoring of a root task in one blob

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>