files: Pass stat information into fd_id_generate_special

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Pass stat information into fd_id_generate

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Make fd_id_generate_special return ID into pointer

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Rework select_ps_list fdsec ops callback

For unlinked opened and mmaped files we'd need to
care about remaps, for this the callback with both
file_desc and fdinfo_list_entry will be required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Cache special file IDs

We have tons of files with equal IDs, e.g. libraries mapped
to different tasks. No need in writing all this duplicate
stuff into images -- cache the IDs with dev:ino keys.

Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Properlu count number of users for mmaped/exe-d ghost files

If a file mmaped or pointed by exe link is unlinked, we will
generate a ghost file for it. On restore the ghost file will
be created with the users counter 1 and the very first open
(e.g. for mmap) will unlink the file.

Handle this by bumping up user counter for every mapping
pointing on the file.

This appeared after previous patches that packed the reg-files
image. Before it each vma and exe link created separate entry
in the reg-files image.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
collect: Add comment describing collect order

With packed reg-files we have a complex fd - file - vma - remap interaction. I
think this should be reflected in the code comment.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: A bunch of test for various flavors of unlinked/opened/maped files

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