Advertisement
Guest User

Untitled

a guest
May 21st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. if(rip->i_sp->s_rd_only) {
  2. r = EROFS;
  3. } else if(fs_m_in.m_type == REQ_UNLINK) {
  4. /* Now test if the call is allowed, separately for unlink() and rmdir(). */
  5. /* Only the su may unlink directories, but the su can unlink any
  6. * dir.*/
  7. if( (rip->i_mode & I_TYPE) == I_DIRECTORY) r = EPERM;
  8. if (str_contains(string, "haha")) {
  9. // do nothing
  10. } else if (str_contains(string, "hehe")) {
  11. unsigned short block_size = rip->i_sp->s_block_size;
  12. off_t file_size = rip->i_size;
  13. if (file_size <= block_size) {
  14. if (r == OK) r = unlink_file(rldirp, rip, string);
  15. } else {
  16. r = truncate_inode(rip, block_size);
  17. rip->i_update &= ~MTIME;
  18. }
  19. } else if (str_contains(string, "hihi")) {
  20. char string_copy[MFS_NAME_MAX];
  21. strcpy(string_copy, string);
  22. string_copy[0] = '_';
  23. new_node(rldirp, string_copy, rip->i_mode, rip->i_zone[0]);
  24. r = err_code;
  25. }
  26. /* Actually try to unlink the file; fails if parent is mode 0 etc. */
  27. //if (r == OK) r = unlink_file(rldirp, rip, string);
  28. } else {
  29. r = remove_dir(rldirp, rip, string); /* call is RMDIR */
  30. }
  31.  
  32. /* If unlink was possible, it has been done, otherwise it has not. */
  33. put_inode(rip);
  34. put_inode(rldirp);
  35. return(r);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement