files: Remove obsolete fmap_fd structure

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
log: change a logging descriptor when it was initialized

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
log: don't close STDERR

reopen_fd_as closes old descriptor.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
log: don't fail if a log descriptor is reopened

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Factor out dump-regs logging

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Move dump-personality logs into dumper fn

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Toss code withing dump_task_core_all

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Remove unused brk on-stack var from dump_task_core_all

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fd: Sanitize fd_parms fd_name field

It used to be ulong, but it can be int now (no mapping addresses there). And the
name fd is better than fd_name (reason is the same).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets: Pass fd_parms into sockets dumping fns

This is required for proper close-on-exec handling (coming soon) and for fowners (coming soon
as well) and for file flags (yes, yes).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Rename fd dumping functions

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
syscall: Add fcntl syscall and F_GETFD cmd

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util-net: Make send/recv fds carry fd flags in message

The flags are only one bit in the kernel (close-on-exec, all the rest are not per-fd, but per-file),
but for simplicity I save it in a char field.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fd: Handle close-on-exec bits

This bit is not per-file, but per-fd, thus put it on the fdinfo_entry.
Draing these bits from parasite together with the fds themselves, save
into image and restore with fcntl F_SETFD cmd where applicable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add test for close-on-exec bits

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Drop redundant lseek in prepare_fds

No need to obtain MAGIC_OFFSET from current position,
the files have predefined structure.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Print the state of files restoring transition

It's confusing to see the output like

 | Got fd for 3
 | Got fd for 3

Better to point what is going on

 | Got fd for 3 (state -> 0)
 | Got fd for 3 (state -> 1)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Don't call for run_unix_connections if there error happened earlier

It doesn't make sense to try to connect sockets if error
happened previously.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets: Save and restore fd flags for sockets

For regfiles this is done at open() time, for pipes thit is done with fcntl. Use
the same fcntl approach for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Don't kill tasks after failed dump

This is not very good practice :) Just leave them in the state they've been to before
dumping. Plz note, that tasks segfault for some reason after unseizeing, but this is
another story.

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