So I'm trying to write a C program that uses inotify. I've used pyinotify before so I understand how it works. However, I'm following some guide and it tells me to include <linux/inotify.h>
. The problem is that this header only has macro definitions, not the funciton prototypes. It looks like the functions are prototyped in <sys/inotify.h>
.
My question is what's the difference between linux/inotify.h
and sys/inotify.h
? Why are there both?
With Inotify, anti-virus detectors re-scan the file system for modified files to detect if any malicious intrusions have occurred. This kind of applications use a user-space device through which Inotify events are triggered between the kernel and user-space applications.
DESCRIPTION top. The inotify API provides a mechanism for monitoring filesystem events. Inotify can be used to monitor individual files, or to monitor directories. When a directory is monitored, inotify will return events for the directory itself, and for files inside the directory.
Introducing inotify 13 kernel, Linux has included inotify, which allows a monitoring program to open a single file descriptor and watch one or more files or directories for a specified set of events, such as open, close, move/rename, delete, create or change attributes.
Inotify Watch helps to keep track of the file changes under the directories on "watch" and report back to the application in a standard format using the API calls. We can monitor multiple file events under the watched directory using the API calls.
sys/inotify.h
is part of the GNU C library. It exposes the structures and functions that your program will use in order to receive filesystem change notifications. It can be considered as the public API of the notification system.
linux/inotify.h
is part of the Linux kernel. It defines the kernel structures and constants used to implement the notification system itself. You shouldn't include that file unless you're writing something like a kernel module, because it's Linux-specific and thus not portable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With