build: Move protobuf-desc-gen.sh into scripts/

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
build: Move pie/gen-offsets.sh into scripts/

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fsnotify: Simplify get_mark_path code

Handle the simplest (remap) case early. This makes code
simpler and reduces one level of indent.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fsnotify: Don't crash on bad fsnotify mark type

This can be broken image, need to handle this error gracefully.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fsnotify: Move decoding handle into function

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fsnotify: Add comment saying why we attach watches via /proc/self/fd/

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fsnotify: Print wd being restored for inotify

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inotify: Sort marks by wd before collecting them

The inotify_add_watch generates wd-s one-by one. We cannot
request for one, thus we call this syscall till the required
wd is generated.

Thus, if we want to restore several wd-s for an inotify, we
have to put them in ascending order. Otherwise we may restore
watch with higher wd earlier and will thus not be able to
generate the lower wd in a reasonable time.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inotify: Optimize ify search when collecting wd for it

CRIU puts wd-s for one inotify in one row (one after another),
so when collecting next wd, we can find the ify to attach them
to faster.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inotify: Sanitize watches adding loop

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files-reg: Sanitize ghost files re-opening for read

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: Introduce buffer size for carrying /proc/self/fd/N path

There's ... a number of places where we want to do something
with /proc/self/fd/%d path. Each time we guess buffer size
that is enough for this. Make standard constant for this and
save some space on stack and drop args for some functions.

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