예제 #1
0
파일: super.c 프로젝트: HarryR/sanos
int dfs_format(vfs_devno_t devno, char *opts)
{
  int blocksize;
  int inode_ratio;
  int quick;
  struct filsys *fs;

  blocksize = DEFAULT_BLOCKSIZE;
  inode_ratio = DEFAULT_INODE_RATIO;
  quick = 0;
  if (parse_options(opts, &blocksize, &inode_ratio, &quick) != 0) return -1;
  fs = create_filesystem(devno, blocksize, inode_ratio, quick);
  if (!fs) return -1;
  close_filesystem(fs);
  return 0;
}
예제 #2
0
	FileSystem(const char* volume, uint32_t size_):
		volume_name(volume){

		int32 initialize_result = 0;
		int8_t volume_name_found = 0;

		size = size_;

		//Find offset from GlobalFilesystemHandler:
		//(uint32_t)&eeprom_buffer +
		name_offset = GlobalFileSystemHandler::get_instance().add_new_filesystem(this, size);
		header_offset = name_offset + EEFS_MAX_DEVICENAME_SIZE;

		//Check if the given volume name is found at that offset:
		if(!volume_exist(volume, name_offset)){
			//No volume by that name exist at the given offset.
			//Are we allowed to create a new filesystem?
			bool generate_new_filesystem = GlobalFileSystemHandler::get_instance().get_generate_new_filesystem_flag();
			if(!generate_new_filesystem){
				//No we are not. Then we'll have to call the corrupted filesystem hook:
				CORRUPTED_FILESYSTEM_HOOK;

				//Now it's OK to create the new filesystem!
				GlobalFileSystemHandler::get_instance().set_generate_new_filesystem_flag(1);
			}

			Debug.put("\n\rCreating new volume: ");
			Debug.put(volume);
			create_filesystem(volume, name_offset, size);
		}

		//Initialize filesystem:
		initialize_result = EEFS_InitFS(const_cast<char*>(volume_name), header_offset);

		//If the filesystem doesn't exist for some reason.
		if(initialize_result == EEFS_NO_SUCH_DEVICE){
				//Something is very wrong!!
				while(1);
		}

		eefs_device = EEFS_GetDevicePtr(initialize_result);
		initialize_result = EEFS_Mount(const_cast<char*>(volume_name), const_cast<char*>(volume_name));

		Debug.transmit();
	}