files: Support ghost directories restore

If we have opened and rmdir-ed directory, the dump works OK
creating the ghost file and remap, but restore creates _file_
instead of directory.

Fix this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add test for opened ghost directory

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Rename prepare_fs into restore_fs

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Split fs restore into prepare and restore

The prepare one will become more complicated soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Split open_reg_by_id into two parts

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Fix restoration of ghost cwd (and root)

When cwd is removed (it can be) we need to collect the respective
file_desc before starting opening any files to properly handle
ghost refcounts. Otherwise we will miss one refcount from the
cwd's on ghost, which in turn will either BUG inside ghost removal,
or will fail the cwd due to the respective dir being removed too
early.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add test for cwd ghost directory

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add test for cwd and opened ghost directory

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm/socket-tcpbuf: add shortcuts for RDWRing a specified size of data

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
test/socket-tcpbuf: add heartbeat to make blood flow in the connection

Otherwise the connection can be disconnected due to a timeout, because
the kernel may drop packets from a receive queue (RcvPruned in
/proc/net/netstat).

Half of buffers always stay in the socket, another half is circulated.

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