Advertisement
Guest User

Untitled

a guest
May 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. void processInodeBitmap()
  2. {
  3. int i, inodeNumber;
  4. char file_type[5], creation_time[64], mod_time[64];
  5. uint16_t = link_count, file_mode;
  6. uint32_t owner, group_of_inode;
  7. uint64_t file_size, number_of_blocks;
  8.  
  9. valid_inodes = malloc(super_summary->inode_num * sizeof(int));
  10. for (i = 0; i < num_groups; i++)
  11. {
  12. int j;
  13. int usize = (group_summaries[i].num_blocks/8)
  14. for (j = 0; j < usize; j++)
  15. {
  16. pread(file_fd, &buf_8, 1, (group_summaries[i].free_inode_bitmap_blocknum * super_summary->block_size) + j);
  17. int bit;
  18. for(bit = 1; bit <= 8; bit++)
  19. {
  20. int ind_val = buf_8 & mask;
  21. int correct_location = j*8 + bit;
  22. if( ind_val != 0 && ( correct_location <= group_summaries[i].num_inodes)) // is the inode free
  23. {
  24. // find inode number
  25. inodeNumber = correct_location + (i * group_summaries[i].num_inodes);
  26.  
  27. // find file type
  28. pread(file_fd, &buf_16, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + correct_location*INODE_SIZE);
  29.  
  30. if(buf_16 & 0x8000)
  31. {
  32. strcpy(file_type, "f");
  33. }
  34. else if(buf_16 & 0xA000)
  35. {
  36. strcpy(file_type, "s");
  37. }
  38. else if(buf_16 & 0x4000)
  39. {
  40. strcpy(file_type, "d");
  41. }
  42. else
  43. {
  44. strcpy(file_type, "?");
  45. }
  46.  
  47. //find file mode
  48. file_mode = buf_16; //print this in OCTAL
  49.  
  50. //get owner
  51. pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 2);
  52. owner = buf_32;
  53. pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 120);
  54. owner |= (buf_32 << 16);
  55.  
  56. //find group
  57. pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 24);
  58. group_of_inode = buf_32;
  59. pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 122);
  60. group_of_inode |= (buf_32 << 16);
  61.  
  62. //find link count
  63. pread(file_fd, &buf_16, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 26);
  64. link_count = buf_16
  65.  
  66. //find creation time
  67. pread(file_fd, &buf_32, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 12);
  68. //TODO:figure this out
  69.  
  70.  
  71. //find modification time
  72. //TODO: figure this out too
  73.  
  74. //find time of last acess
  75. //this too
  76.  
  77. //get file size
  78. pread(file_fd, &buf_64, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 4);
  79. file_size = buf_64;
  80. pread(file_fd, &buf_64, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 108)
  81. file_size |= (buf_64 << 32);
  82.  
  83. //get number of blocks
  84. pread(file_fd, &buf_32, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 28);
  85. number_of_blocks = buf32/(super_summary->block_size/512);
  86.  
  87. fprintf(stdout, "COOOOOOOOOONS");
  88. }
  89.  
  90. mask <<= 1;
  91.  
  92. }
  93. }
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement