fsnotify: Filter event mask from old kernels

When checkpoint is done on the kernels where
commit 6933599697c96c3213c95f5f1fc7cb6abfd08c54
is not yet present then mask is not filtered
and saved in image in this raw form.

For such case restore on more modern kernels
will fail because only a small set of events
are allowed to pass from userspace.

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Cyrill Gorcunov 2017-10-02 10:07:48 +03:00 committed by Andrei Vagin
parent 251b4d06a9
commit 4ff68eeb36

View file

@ -551,12 +551,19 @@ static int restore_one_inotify(int inotify_fd, struct fsnotify_mark_info *info)
InotifyWdEntry *iwe = info->iwe;
int ret = -1, target = -1;
char buf[PSFDS], *path;
uint32_t mask;
path = get_mark_path("inotify", info->remap, iwe->f_handle,
iwe->i_ino, iwe->s_dev, buf, &target);
if (!path)
goto err;
mask = iwe->mask & IN_ALL_EVENTS;
if (iwe->mask & ~IN_ALL_EVENTS) {
pr_info("\t\tfilter event mask %#x -> %#x\n",
iwe->mask, mask);
}
/*
* FIXME The kernel allocates wd-s sequentially,
* this is suboptimal, but the kernel doesn't
@ -565,7 +572,7 @@ static int restore_one_inotify(int inotify_fd, struct fsnotify_mark_info *info)
while (1) {
int wd;
wd = inotify_add_watch(inotify_fd, path, iwe->mask);
wd = inotify_add_watch(inotify_fd, path, mask);
if (wd < 0) {
pr_perror("Can't add watch for 0x%x with 0x%x", inotify_fd, iwe->wd);
break;