Click here to Skip to main content
14,836,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
void inotifyFunc(char *path char *command){
    monitor.fd = inotify_init();
    if(fcntl(monitor.fd, F_SETFL, O_NONBLOCK)){
       perror("inotify not initialized: ");
       exit(0);
    }
    // ENOENT is replaced with command
    monitor.wd = inotify_add_watch(monitor.fd, path, command);
    if(monitor.wd < 0){
        perror("Sorry");
        exit(1);
    }
    else{
        printf("Location '%s' is being monitored\n\n", path);
    }
}


What I have tried:

In this code, I am trying to write `inotifyFunc(pathname, command)`. The pathname is declared in the function and the `command variable` should be for `ENOENT`. It means whenever I try to execute and make changes in the filesystem, I should just write the pathname and a command(IN_CREATE, IN_MODIFY, etc) using inotifyFunc() in the main function. 

But it is not working and giving me the error message

warning: passing argument 3 of ‘inotify_add_watch’ makes integer from pointer without a cast 
Posted
Updated 1-Jan-21 6:51am

1 solution

See the man page: inotify_add_watch(2) - Linux manual page[^] for the correct parameters to the inotify_add_watch command.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900