Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void processInodeBitmap()
- {
- int i, inodeNumber;
- char file_type[5], creation_time[64], mod_time[64];
- uint16_t = link_count, file_mode;
- uint32_t owner, group_of_inode;
- uint64_t file_size, number_of_blocks;
- valid_inodes = malloc(super_summary->inode_num * sizeof(int));
- for (i = 0; i < num_groups; i++)
- {
- int j;
- int usize = (group_summaries[i].num_blocks/8)
- for (j = 0; j < usize; j++)
- {
- pread(file_fd, &buf_8, 1, (group_summaries[i].free_inode_bitmap_blocknum * super_summary->block_size) + j);
- int bit;
- for(bit = 1; bit <= 8; bit++)
- {
- int ind_val = buf_8 & mask;
- int correct_location = j*8 + bit;
- if( ind_val != 0 && ( correct_location <= group_summaries[i].num_inodes)) // is the inode free
- {
- // find inode number
- inodeNumber = correct_location + (i * group_summaries[i].num_inodes);
- // find file type
- pread(file_fd, &buf_16, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + correct_location*INODE_SIZE);
- if(buf_16 & 0x8000)
- {
- strcpy(file_type, "f");
- }
- else if(buf_16 & 0xA000)
- {
- strcpy(file_type, "s");
- }
- else if(buf_16 & 0x4000)
- {
- strcpy(file_type, "d");
- }
- else
- {
- strcpy(file_type, "?");
- }
- //find file mode
- file_mode = buf_16; //print this in OCTAL
- //get owner
- pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 2);
- owner = buf_32;
- pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 120);
- owner |= (buf_32 << 16);
- //find group
- pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 24);
- group_of_inode = buf_32;
- pread(file_fd, &buf_32, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 122);
- group_of_inode |= (buf_32 << 16);
- //find link count
- pread(file_fd, &buf_16, 2, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 26);
- link_count = buf_16
- //find creation time
- pread(file_fd, &buf_32, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 12);
- //TODO:figure this out
- //find modification time
- //TODO: figure this out too
- //find time of last acess
- //this too
- //get file size
- pread(file_fd, &buf_64, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 4);
- file_size = buf_64;
- pread(file_fd, &buf_64, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 108)
- file_size |= (buf_64 << 32);
- //get number of blocks
- pread(file_fd, &buf_32, 4, group_summaries[i].free_inode_bitmap_blocknum * super_summary.block_size + (correct_location - 1)*INODE_SIZE + 28);
- number_of_blocks = buf32/(super_summary->block_size/512);
- fprintf(stdout, "COOOOOOOOOONS");
- }
- mask <<= 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement