Commit 61859d11 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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/680Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9f631ad5
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment