fanotify and namespaces/bind mounts

From: Marko Rauhamaa
Date: Thu Oct 29 2015 - 09:53:56 EST

If I call fanotify_mark(... FAN_MARK_ADD | FAN_MARK_MOUNT ...), I get
notifications on all files on the file system.

Except I don't.

If a process has mounted directories on the file system in a different
namespace, the global namespace experiences file system events but no
fanotify events are generated. A similar limitation applies to bind

You can easily see this behavior in action. Do "man fanotify", and copy
the example program to, say, example.c. Then,

cc -o example example.c
mkdir -p /mnt/xyz
mount -o bind /root /mnt/xyz
./example /root

The last command prints out fanotify events. It will display events for

touch /root/xyzzy

but nothing for

touch /mnt/xyz/zyxxy


unshare -m touch /root/yxyyx

Should the current situation be considered a bug in fanotify? Or is
there another recommended way to monitor file system events

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at