1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int handle_perm(int fan_fd, struct fanotify_event_metadata *metadata) { struct fanotify_response response_struct; int ret; response_struct.fd = metadata->fd; response_struct.response = FAN_DENY;// 唯一的修改 ret = write(fan_fd, &response_struct, sizeof(response_struct)); if (ret < 0) return ret; return 0; } |
1 | ./av -p /home/lm/f1 |
1 2 | [lm@localhost ~]$ cat f1 cat: f1: Operation not permitted |
1 2 3 4 5 | read(metadata->fd,buf1,sizeof(buf1)); if(strncmp(buf1,"stub",4)==0) { write(metadata->fd,"abcd",4); } |
1 | [lm@localhost ~]$ echo “stub” >hsmt |
1 2 3 4 5 | [lm@localhost ~]$ ./hsm ~/hsmt 在另外的窗口执行 cat [lm@localhost ~]$ cat ~/hsmt abcd |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |