Advertisement
Guest User

Untitled

a guest
Feb 10th, 2015
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. struct file *fget(unsigned int fd)
  2. {
  3. struct file *file;
  4. struct files_struct *files = current->files;
  5.  
  6. rcu_read_lock();
  7. file = fcheck_files(files, fd);
  8. if (file) {
  9. /* File object ref couldn't be taken */
  10. if (file->f_mode & FMODE_PATH ||
  11. !atomic_long_inc_not_zero(&file->f_count))
  12. file = NULL;
  13. }
  14. rcu_read_unlock();
  15.  
  16. return file;
  17. }
  18.  
  19. asmlinkage int custom_read(int fd, void *buf, size_t noct)
  20. {
  21. struct file *filp = fget(fd);
  22. unsigned char f_name[DNAME_INLINE_LEN];
  23. strcpy(f_name,filp->f_path.dentry->d_name.name);
  24. // if (!strcmp(f_name, "_ttt.c")){
  25. // printk("hook1: read fd=(%d: -> %s)\n",fd,f_name);
  26. // return -1;
  27. // }
  28. return original_read(fd, buf, noct);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement