SHARE
TWEET

Untitled

a guest Jun 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. vdi1 17GBs
  2. >------------File System info---------------
  3. >Total file system size in bytes: 1140850688
  4. >Size available for files, used and unused:
  5. >Amount of space currently used: 2509353121
  6. >Number of possible files and directories: 1569648350
  7. >Number of existing files:
  8. >Number of existing directories: 0
  9. >Number of block groups: 0
  10. >Block size in bytes: 16777216
  11. >Magic number: 9330
  12. >Error with fileSysState number. 28582
  13.  
  14. vdi2 37GBs
  15. >------------File System info---------------
  16. >Total file system size in bytes: 42082304
  17. >Size available for files, used and unused:
  18. >Amount of space currently used: 1518474772
  19. >Number of possible files and directories: 352321745
  20. >Number of existing files:
  21. >Number of existing directories: 0
  22. >Number of block groups: 0
  23. >Block size in bytes: 1024
  24. >Magic number: 510
  25. >Error with fileSysState number. 5120
  26.      
  27. 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.
  28.     vdiSeek(vdi_ptr, 1024, 0);
  29.     vdiRead(vdi_ptr, superblock_ptr, 84);
  30.  
  31.      //if(superblock_ptr->revLevel >= 1){
  32.         //vdiSeek(vdi_ptr, 1024+83, SEEK_START);
  33.         //vdiRead(vdi_ptr, superblock_ptr,
  34. //}
  35. }
  36.      
  37. ssize_t vdiRead(struct vdiFile *vdi_ptr, void *buffer, size_t length){
  38.  
  39.     int blockNum = vdi_ptr->cursor / vdi_ptr->vdiStruct.blockSize;
  40.     int offset = vdi_ptr->cursor % vdi_ptr->vdiStruct.blockSize;
  41.     int pos = (vdi_ptr->vdiStruct.offsetBlocks + blockNum) * vdi_ptr->vdiStruct.blockSize;
  42.  
  43.     lseek(vdi_ptr->fileDesc, pos, SEEK_CUR);
  44.  
  45.     int realBlockNum;
  46.     read(vdi_ptr->fileDesc, &realBlockNum, 1);
  47.  
  48.     int start = (vdi_ptr->vdiStruct.offsetBlocks + realBlockNum) * vdi_ptr->vdiStruct.blockSize + offset;   // location of the data to start
  49.  
  50.     lseek(vdi_ptr->fileDesc, start, SEEK_CUR);
  51.  
  52.     // read in the data to the buffer from start to length
  53.     vdi_ptr->cursor += length;
  54.     return read(vdi_ptr->fileDesc, buffer, length);
  55. }
  56.      
  57. typedef struct __attribute__((__packed__)) superblockStructure{ // superblock is always located at byte 1024
  58.     uint32_t iNodeCount,
  59.             blocksCount,
  60.             superUserBlocks,
  61.             freeBlocks,
  62.             freeInodes,
  63.             firstDataBlock,
  64.             logBlockSize,
  65.             logFragSize,
  66.             blocksPerGroup,
  67.             fragsPerGroup,
  68.             iNodesPerGroup,
  69.             mountTime,
  70.             writeTime;
  71.     uint16_t mountCount,
  72.             maxMountCount,
  73.             magicNum,
  74.             fileSysState, //1: clean; 2: error
  75.             errors, // 1: continue, 2:remount as read only, 3: kernel panic
  76.             minorRevLevel;
  77.     uint32_t lastCheck,
  78.             checkInterval,
  79.             creatorOS,
  80.             revLevel;
  81.     uint16_t defaultUserIdReservedBlocks,
  82.             defaultGroupIdReservedBlocks;
  83. }superblockStructure;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top