tty: Align members in assignments

For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tty: Instead of BUG_ON exit out with error early

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tty: Add some comments about console and bsd terminals

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tty: Rename helpers to reflect the type of peers

 - parse_index -> parse_pty_index since it's PTY specific
 - pty_is_master -> tty_is_master because it will test
   not only PTY peers but other types as well
 - pty_is_hung -> tty_is_hung for same reason

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tty: collect_one_tty -- Use tty_is_master helper

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tty: proto -- Add comments on some fields

Actually these @locked and @packet_mode are
valid for unix98 ptys only so since moving
them into @tty_pty_entry is impossible at
least lets comment this.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: don't race when closing cg yard

TASK_HELPERs are created with CLONE_FILES, so if we always close the cg yard
here, it will close it for the other helpers and cause problems. Instead, we
close it much later, in code only called by alive tasks, to ensure that there
is no conflict.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
add int(CTL_32)

Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm/stopped: fix stopped test

The main problem with the
test that it's never 'fail'.
Test can only 'pass' or hangs.

Signed-off-by: Konstantin Neumoin <kneumoin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mount: don't create a temporary directory for pivot_root()

I found this solution in the LXC code. We can open the old root, call
pivot_root(".", "."), call fchdir to the old root and call umount(".").

Now restore will not fail, if the root is read-only.
In addition it's a bit faster.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: clear breakpoints only for alive tasks

We don't set breakpoints for zombies.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
check: make check_ptrace_peeksiginfo and check_sigqueuinfo as static

They are not used outside.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: pre-load kernel modules

See the comment below for an explanation of what is going on. We will
ultimately need to handle dumping the netlink data, but I think it is good to
prevent injecting events into the stream during a dump. So we pre-load the
modules, even though it isn't very pretty.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
travis: add compilation of tests

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

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
net: Use ns walking helper

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mnt: Clean up namespaces walking code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mnt: Use ns walking helper

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pstree: Add helper for adding helpers to pstree

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: don't play with a function exit code

We should not have a chance to exit with a wrong code on error paths.

Now dump_one_task() returs zero, if allocation of dfds failed:

ret = collect_mappings(pid, &vmas);
if (ret) {
	pr_err("Collect mappings (pid: %d) failed with %d\n", pid, ret);
	goto err;
}

if (!shared_fdtable(item)) {
	dfds = xmalloc(sizeof(*dfds));
	if (!dfds)
		goto err;

...
err:
	return -1;

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