bool PartitionHandle::Mount(int pos, const char * name) { if(!valid(pos)) return false; if(!name) return false; UnMount(pos); if(pos >= (int) MountNameList.size()) MountNameList.resize(GetPartitionCount()); MountNameList[pos] = name; if(strncmp(GetFSName(pos), "FAT", 3) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0) { if (fatMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS)) { if(strcmp(GetFSName(pos), "GUID-Entry") == 0) PartitionList[pos].FSName = "FAT"; return true; } } if(strncmp(GetFSName(pos), "NTFS", 4) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0) { if(ntfsMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER)) { PartitionList[pos].FSName = "NTFS"; return true; } } if(strncmp(GetFSName(pos), "LINUX", 5) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0) { if(ext2Mount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, EXT2_FLAG_DEFAULT)) { PartitionList[pos].FSName = "LINUX"; return true; } } MountNameList[pos].clear(); return false; }
/** * * This function loads all partition header information in global array * * @param ImageAddress is the start address of the image * * @return - XST_SUCCESS if Get partition Header information successful * - XST_FAILURE if Get Partition Header information failed * * @note None * ****************************************************************************/ u32 GetPartitionHeaderInfo(u32 ImageBaseAddress) { u32 PartitionHeaderOffset; u32 Status; /* * Get the length of the FSBL from BootHeader */ Status = GetFsblLength(ImageBaseAddress, &FsblLength); if (Status != XST_SUCCESS) { fsbl_printf(DEBUG_GENERAL, "Get Header Start Address Failed\r\n"); return XST_FAILURE; } /* * Get the start address of the partition header table */ Status = GetPartitionHeaderStartAddr(ImageBaseAddress, &PartitionHeaderOffset); if (Status != XST_SUCCESS) { fsbl_printf(DEBUG_GENERAL, "Get Header Start Address Failed\r\n"); return XST_FAILURE; } /* * Header offset on flash */ PartitionHeaderOffset += ImageBaseAddress; fsbl_printf(DEBUG_INFO,"Partition Header Offset:0x%08x\r\n", PartitionHeaderOffset); /* * Load all partitions header data in to global variable */ Status = LoadPartitionsHeaderInfo(PartitionHeaderOffset, &PartitionHeader[0]); if (Status != XST_SUCCESS) { fsbl_printf(DEBUG_GENERAL, "Header Information Load Failed\r\n"); return XST_FAILURE; } /* * Get partitions count from partitions header information */ PartitionCount = GetPartitionCount(&PartitionHeader[0]); fsbl_printf(DEBUG_INFO, "Partition Count: %d\r\n", PartitionCount); /* * Partition Count check */ if (PartitionCount >= MAX_PARTITION_NUMBER) { fsbl_printf(DEBUG_GENERAL, "Invalid Partition Count\r\n"); return XST_FAILURE; #ifndef MMC_SUPPORT } else if (PartitionCount <= 1) { fsbl_printf(DEBUG_GENERAL, "There is no partition to load\r\n"); return XST_FAILURE; #endif } return XST_SUCCESS; }