Beispiel #1
0
int myMount(MyFileSystem *myFileSystem, char *backupFileName){
	if ((myFileSystem->fdVirtualDisk = open(backupFileName, O_RDWR))==-1){
		perror(backupFileName);
		return 1;
	}
	
	if (readBitmap(myFileSystem)!=0){
		fprintf(stderr,"Can't read bitmap\n");
		return 2;
	}
	
	if (readSuperblock(myFileSystem)!=0){
		fprintf(stderr,"Can't read superblock\n");
		return 3;
	}

	if (readInodes(myFileSystem)!=0){
		fprintf(stderr,"Can't read inodes\n");
		return 4;
	}	

	if (readDirectory(myFileSystem)!=0){
		fprintf(stderr,"Can't read directory\n");
		return 5;
	}
	
	printf("SF: %s, %d B (%d B/block), %d blocks\n", backupFileName, myFileSystem->superBlock.diskSizeInBlocks*BLOCK_SIZE_BYTES, BLOCK_SIZE_BYTES, myFileSystem->superBlock.diskSizeInBlocks);
	printf("1 block for SUPERBLOCK (%u B)\n", (unsigned int)sizeof(SuperBlockStruct));
	printf("1 block for BITMAP, covering %u blocks, %u B\n", (unsigned int)NUM_BITS, (unsigned int)(NUM_BITS * BLOCK_SIZE_BYTES));
	printf("1 block for DIRECTORY (%u B)\n", (unsigned int)sizeof(DirectoryStruct));
	printf("%d blocks for inodes (%u B/inode, %u inodes)\n", MAX_BLOCKS_WITH_NODES, (unsigned int)sizeof(NodeStruct), (unsigned int)MAX_NODES);
	printf("%d blocks for data (%d B)\n", myFileSystem->superBlock.numOfFreeBlocks, BLOCK_SIZE_BYTES * myFileSystem->superBlock.numOfFreeBlocks);
	printf("Volume mounted successfully!\n");
	return 0;
} 
Beispiel #2
0
void FileSystem::startFileSystemChecking() {
  PartitionEntry *entry = getPartitionTable(0, 0);
  progressBar->setValue(10);
  PartitionEntry *temp = entry;
  while (temp != NULL) {
    if (temp->type == EXT2_PARTITION) {
      readSuperblock(temp);
      setInfo();
      readRootInode(temp);
      freeInfo();
    }
    temp = temp->next;
    progressBar->setValue(progressBar->value() + 30);
  }
}