Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vdi1 17GBs
- >------------File System info---------------
- >Total file system size in bytes: 1140850688
- >Size available for files, used and unused:
- >Amount of space currently used: 2509353121
- >Number of possible files and directories: 1569648350
- >Number of existing files:
- >Number of existing directories: 0
- >Number of block groups: 0
- >Block size in bytes: 16777216
- >Magic number: 9330
- >Error with fileSysState number. 28582
- vdi2 37GBs
- >------------File System info---------------
- >Total file system size in bytes: 42082304
- >Size available for files, used and unused:
- >Amount of space currently used: 1518474772
- >Number of possible files and directories: 352321745
- >Number of existing files:
- >Number of existing directories: 0
- >Number of block groups: 0
- >Block size in bytes: 1024
- >Magic number: 510
- >Error with fileSysState number. 5120
- void getSuperblock(struct vdiFile *vdi_ptr, struct superblockStructure *superblock_ptr){//ask if you how to pass in the struct itself as the buffer its reading into.
- vdiSeek(vdi_ptr, 1024, 0);
- vdiRead(vdi_ptr, superblock_ptr, 84);
- //if(superblock_ptr->revLevel >= 1){
- //vdiSeek(vdi_ptr, 1024+83, SEEK_START);
- //vdiRead(vdi_ptr, superblock_ptr,
- //}
- }
- ssize_t vdiRead(struct vdiFile *vdi_ptr, void *buffer, size_t length){
- int blockNum = vdi_ptr->cursor / vdi_ptr->vdiStruct.blockSize;
- int offset = vdi_ptr->cursor % vdi_ptr->vdiStruct.blockSize;
- int pos = (vdi_ptr->vdiStruct.offsetBlocks + blockNum) * vdi_ptr->vdiStruct.blockSize;
- lseek(vdi_ptr->fileDesc, pos, SEEK_CUR);
- int realBlockNum;
- read(vdi_ptr->fileDesc, &realBlockNum, 1);
- int start = (vdi_ptr->vdiStruct.offsetBlocks + realBlockNum) * vdi_ptr->vdiStruct.blockSize + offset; // location of the data to start
- lseek(vdi_ptr->fileDesc, start, SEEK_CUR);
- // read in the data to the buffer from start to length
- vdi_ptr->cursor += length;
- return read(vdi_ptr->fileDesc, buffer, length);
- }
- typedef struct __attribute__((__packed__)) superblockStructure{ // superblock is always located at byte 1024
- uint32_t iNodeCount,
- blocksCount,
- superUserBlocks,
- freeBlocks,
- freeInodes,
- firstDataBlock,
- logBlockSize,
- logFragSize,
- blocksPerGroup,
- fragsPerGroup,
- iNodesPerGroup,
- mountTime,
- writeTime;
- uint16_t mountCount,
- maxMountCount,
- magicNum,
- fileSysState, //1: clean; 2: error
- errors, // 1: continue, 2:remount as read only, 3: kernel panic
- minorRevLevel;
- uint32_t lastCheck,
- checkInterval,
- creatorOS,
- revLevel;
- uint16_t defaultUserIdReservedBlocks,
- defaultGroupIdReservedBlocks;
- }superblockStructure;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement