0

I want to write a functionality which will check whether fanotify API is enabled or disabled by kernel.

If it is enabled then only my program should proceed further otherwise it should return FALSE.

I want write a generic function which will work on all linux distros. Can someone please help to get this resolved?

After doing some search I have found it is configured in /boot/config-<kernel_version> file.

Suyog
  • 21
  • 3
  • `zgrep CONFIG_FANOTIFY /proc/config.gz`. But what's wrong with just calling `fanotify_init` and checking errno? – KamilCuk Aug 10 '20 at 12:00
  • @KamilCuk , i have all the functionality of fanotify_init, fanotify_mark and it is mounting a path and scanning it, but before going to that process, i want to verify whether fanotify is enabled in kernel. – Suyog Aug 10 '20 at 12:20
  • 1
    Yes, so call `fanitofiy_init` and __check errno__. – KamilCuk Aug 10 '20 at 12:26
  • Hi @KamilCuk , does fanotify_init handle a case where CONFIG_FANOTIFY is enabled but CONFIG_FANOTIFY_ACCESS_PERMISSIONS is disabled. or both disabled. – Suyog Aug 10 '20 at 13:22
  • [What research did you do?](https://stackoverflow.com/questions/34766479/how-to-find-out-whether-config-fanotify-access-permissions-is-enabled). Still checking `/proc/config.gz` would be the best, if it's available. Side note: still your quesiton seems XY question. Why would want to detect kernel support? Just call `fanotify_init` and if it fails, _then_ do something else. Who cares if kernel has support or not, all a user space tool should be interested in is if the call succeeded or not and handle errors. – KamilCuk Aug 10 '20 at 13:23

0 Answers0