This void inotifyFunc()
contains one variable as an argument that is char *path
. I want to add another variable also that should contain the address of uint32_t mask
that is basically ENOENT, IN_CREATE, IN_DELETE, etc which is present in inotify_add_watch()
But I don't know how to save uint32_t mask
as a variable.
My main goal is to call this function in the main function by writing a path, and one command(IN_CREATE, IN_DELETE, etc) at a time that I should assign to the path.
I hope you understand my question.
void inotifyFunc(char *path){
monitor.fd = inotify_init();
if(fcntl(monitor.fd, F_SETFL, O_NONBLOCK)){
perror("inotify not initialized: ");
exit(0);
}
monitor.wd = inotify_add_watch(monitor.fd, path, ENOENT);
if(monitor.wd < 0){
perror("Sorry");
exit(1);
}
else{
printf("Location '%s' is being monitored\n\n", path);
}
}
If I get this right
Change:
void inotifyFunc(char *path) {
To:
void inotifyFunc(char *path, uint32_t *mask ) {
And then
uint32_t mask = ENOENT;
inotifyFunc("....", &mask); // Address of (pointer to) mask
Then use
monitor.wd = inotify_add_watch(monitor.fd, path, mask);
EDIT
As I have just read manual page - see comment
Then
monitor.wd = inotify_add_watch(monitor.fd, path, *mask);
Or
void inotifyFunc(char *path, uint32_t mask ) {
and
inotifyFunc("....", mask);