I'm trying to use fanotify on Android and like to archive that with an executable file (compiled with the ndk). I'm using fsmon (small application which calls the fanotify systemcall) to start the monitor. But on executing the file (on a rooted device as root) I'm getting following error:
generic_x86:/data/local/tmp # ./fsmon -B fanotify /storage/emulated/0/
fanotify_init: Function not implemented
fanotify is available in kernel version > 2.6.37 (which is shipped in Android 5+).
I had tried it on a x86-emulator (Android 7) and on a Samsung I9300 armeabi-v7a (Android 6) with CM13 (both rooted).
Kernel version of the x86 emulator: 3.4.67+
and of the Samsung device: 3.0.101-CM-g9c98896
Then I had a look into the x86-emulator goldfish kernel files in /goldfish/fs/notify/fanotify/Kconfig
:
config FANOTIFY
bool "Filesystem wide access notification"
select FSNOTIFY
select ANON_INODES
default n
---help---
Say Y here to enable fanotify suport. fanotify is a file access
notification system which differs from inotify in that it sends
an open file descriptor to the userspace listener along with
the event.
If unsure, say Y.
config FANOTIFY_ACCESS_PERMISSIONS
bool "fanotify permissions checking"
depends on FANOTIFY
depends on SECURITY
default n
---help---
Say Y here is you want fanotify listeners to be able to make permissions
decisions concerning filesystem events. This is used by some fanotify
listeners which need to scan files before allowing the system access to
use those files. This is used by some anti-malware vendors and by some
hierarchical storage managent systems.
If unsure, say N.
So, I set both to Y, make clean
and recompile the kernel - but same problem like before.. Have I overlooked something?
Ok apparently was the fault to use an uppercase "Y" instead of a lowercase "y" ...