#include #include #include #include #include #include #include #include #include #include #define CIFS_IOC_NOTIFY 0x4005cf09 struct __attribute__((__packed__)) smb3_notify { uint32_t completion_filter; bool watch_tree; }; #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 int main() { int fd, rc; struct smb3_notify n; fd = open(".",O_DIRECTORY|O_RDONLY); if (fd < 0) { perror("open"); return EXIT_FAILURE; } n.watch_tree = true; n.completion_filter = ( FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_LAST_WRITE ); rc = ioctl(fd, CIFS_IOC_NOTIFY, &n); close(fd); printf("CIFS_IOC_NOTIFY returned %d, errno:%d\n", rc, errno); }