if (fd < 0) { printf("Fail to initialize inotify.\n"); exit(-1); } for (i=0; i<WD_NUM; wd="inotify_add_watch(fd," add (event- if { len) < buffer) - *)event (((char while *)buffer; inotify_event event len); len='%d.\n",' happens, printf(?Some offset="buffer;" MAX_BUF_SIZE)) buffer, while(len="read(fd," } wd_array[i].wd="wd;" exit(-1); wd_array[i].name); %s.\n?, for watch printf(?Can?t 0) (wd IN_ALL_EVENTS); wd_array[i].name, wd_array[i].name="monitored_files[i];" i++)>mask & IN_ISDIR) { memcpy(strbuf, "Direcotory", 11); } else { memcpy(strbuf, "File", 5); } printf("Object type: %s\n", strbuf); for (i=0; iwd != wd_array[i].wd) continue; printf("Object name: %s\n", wd_array[i].name); break; } printf("Event mask: %08X\n", event->mask); for (i=0; imask & (1<len; event = (struct inotify_event *)(offset + tmp_len); offset += tmp_len; } } } 【编辑推荐】
- 开辟一个Linux调试器(八):客栈展开
- 开辟一个Linux调试器(九):处理变量
- 你懂 Linux 吗?关于 Linux 你可能不是异常懂得的七件事
- 在Mac Linux上若何快速断定一个文件是否是恶意法度榜样?
- 每个开辟人员应当知道的10个Linux敕令
【义务编辑:庞桂玉 TEL:(010)68476606】
推荐阅读
AI重新定义Web安全
云给安然带来的影响距离2006年Amazon宣布EC2办事已经以前了11年,在这11年迈,产生的不仅仅是AWS收入大年夜几十万美金上涨到100多亿美金,更重要的是云计算已经走进每一俭朴业。根据信通院宣布的&ldquo>>>详细阅读
本文标题:Linux inotify功能及实现原理
地址:http://www.17bianji.com/lsqh/37802.html
1/2 1