2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

fsnotify: Filter out internal inotify bits when restoring marks

The kernel prior 4.3 is exporting FS_EVENT_ON_CHILD
bit via procfs fdinfo interface. This bit is kernel's
internal and should not be passed in inotify_add_watch
call. Thus simply filter it out when obtain from old
images for backward compatibility reason.

More details here https://lkml.org/lkml/2015/9/21/680

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov 2015-10-12 20:18:07 +03:00 committed by Pavel Emelyanov
parent 9f631ad5c9
commit 61859d1176
2 changed files with 16 additions and 0 deletions

View File

@ -223,6 +223,10 @@ static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
we->f_handle->bytes, we->f_handle->type,
we->f_handle->handle[0], we->f_handle->handle[1]);
if (we->mask & KERNEL_FS_EVENT_ON_CHILD)
pr_warn_once("\t\tDetected FS_EVENT_ON_CHILD bit "
"in mask (will be ignored on restore)\n");
if (check_open_handle(we->s_dev, we->i_ino, we->f_handle)) {
free_inotify_wd_entry(e);
return -1;
@ -813,6 +817,16 @@ static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
INIT_LIST_HEAD(&mark->list);
mark->remap = NULL;
/*
* The kernel prior 4.3 might export internal event
* mask bits which are not part of user-space API. It
* is fixed in kernel but we have to keep backward
* compatibility with old images. So mask out
* inappropriate bits (in particular fdinfo might
* have FS_EVENT_ON_CHILD bit set).
*/
mark->iwe->mask &= ~KERNEL_FS_EVENT_ON_CHILD;
return collect_inotify_mark(mark);
}

View File

@ -7,6 +7,8 @@
#include "protobuf.h"
#include "protobuf/fsnotify.pb-c.h"
#define KERNEL_FS_EVENT_ON_CHILD 0x08000000
struct fsnotify_params {
u32 faflags;
u32 evflags;