2018-02-09 23:45 GMT+01:00 Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>: > On 09.02.2018 23:56, Andrew Morton wrote: >> On Fri, 9 Feb 2018 18:04:54 +0300 Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> wrote: >> >>> Watch descriptor is id of the watch created by inotify_add_watch(). >>> It is allocated in inotify_add_to_idr(), and takes the numbers >>> starting from 1. Every new inotify watch obtains next available >>> number (usually, old + 1), as served by idr_alloc_cyclic(). >>> >>> CRIU (Checkpoint/Restore In Userspace) project supports inotify >>> files, and restores watched descriptors with the same numbers, >>> they had before dump. Since there was no kernel support, we >>> had to use cycle to add a watch with specific descriptor id: >>> >>> while (1) { >>> int wd; >>> >>> wd = inotify_add_watch(inotify_fd, path, mask); >>> if (wd < 0) { >>> break; >>> } else if (wd == desired_wd_id) { >>> ret = 0; >>> break; >>> } >>> >>> inotify_rm_watch(inotify_fd, wd); >>> } >>> >>> (You may find the actual code at the below link: >>> https://github.com/checkpoint-restore/criu/blob/v3.7/criu/fsnotify.c#L577) Well using a ioctl command to force a specific wd is possible, but isn't it also possible to do a "freeze" of all (inotify) watches which are involved, and "unfreeze" when restoring? Stef