mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-18 01:41:15 +00:00
Ventoy2Disk update:
1. Add UDF filesytem option. 2. Add Cluster Size option. 3. Support FAT32 for disk bigger than 32GB. 4. Fix the format fail issue. 5. Add a tip bubble with cluster size when mouse hover on the file system type string. 6. The secure boot lock character can not show in early Windows, change it to a yellow icon.
This commit is contained in:
@@ -1106,6 +1106,79 @@ static int WriteGrubStage1ToPhyDrive(HANDLE hDrive, int PartStyle)
|
||||
}
|
||||
|
||||
|
||||
static int FormatPart1LargeFAT32(UINT64 DiskSizeBytes, int CluserSize)
|
||||
{
|
||||
MKFS_PARM Option;
|
||||
FRESULT Ret;
|
||||
FATFS FS;
|
||||
|
||||
Option.fmt = FM_FAT32;
|
||||
Option.n_fat = 1;
|
||||
Option.align = 8;
|
||||
Option.n_root = 1;
|
||||
|
||||
if (CluserSize == 0)
|
||||
{
|
||||
// < 32GB select 32KB as cluster size
|
||||
// > 32GB select 128KB as cluster size
|
||||
if (DiskSizeBytes / 1024 / 1024 / 1024 <= 32)
|
||||
{
|
||||
Option.au_size = 32768;
|
||||
}
|
||||
else
|
||||
{
|
||||
Option.au_size = 131072;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Option.au_size = CluserSize;
|
||||
}
|
||||
|
||||
Log("Formatting Part1 large FAT32 ClusterSize:%u(%uKB) ...", CluserSize, CluserSize / 1024);
|
||||
|
||||
disk_io_reset_write_error();
|
||||
|
||||
Ret = f_mkfs(TEXT("0:"), &Option, 0, 8 * 1024 * 1024);
|
||||
if (FR_OK == Ret)
|
||||
{
|
||||
if (disk_io_is_write_error())
|
||||
{
|
||||
Log("Formatting Part1 large FAT32 failed, write error.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log("Formatting Part1 large FAT32 success, now set label");
|
||||
|
||||
Ret = f_mount(&FS, TEXT("0:"), 1);
|
||||
if (FR_OK == Ret)
|
||||
{
|
||||
Log("f_mount SUCCESS");
|
||||
Ret = f_setlabel(TEXT("0:Ventoy"));
|
||||
if (FR_OK == Ret)
|
||||
{
|
||||
Log("f_setlabel SUCCESS");
|
||||
Ret = f_unmount(TEXT("0:"));
|
||||
Log("f_unmount %d %s", Ret, (FR_OK == Ret) ? "SUCCESS" : "FAILED");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("f_setlabel failed %d", Ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("f_mount failed %d", Ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Formatting Part1 large FAT32 failed");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int FormatPart1exFAT(UINT64 DiskSizeBytes)
|
||||
{
|
||||
@@ -1636,6 +1709,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle, int TryId)
|
||||
UINT64 Part1StartSector = 0;
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
BOOL LargeFAT32 = FALSE;
|
||||
|
||||
Log("#####################################################");
|
||||
Log("InstallVentoy2PhyDrive try%d %s PhyDrive%d <<%s %s %dGB>>", TryId,
|
||||
@@ -1737,13 +1811,28 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle, int TryId)
|
||||
Sleep(1000 * 5);
|
||||
}
|
||||
|
||||
Log("Formatting part1 exFAT ...");
|
||||
if (0 != FormatPart1exFAT(pPhyDrive->SizeInBytes))
|
||||
if (GetVentoyFsType() == VTOY_FS_FAT32 && (Part1SectorCount * 512 >= FAT32_MAX_LIMIT))
|
||||
{
|
||||
Log("FormatPart1exFAT failed.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
Log("Formatting part1 large FAT32 ...");
|
||||
LargeFAT32 = TRUE;
|
||||
if (0 != FormatPart1LargeFAT32(pPhyDrive->SizeInBytes, GetClusterSize()))
|
||||
{
|
||||
Log("FormatPart1LargeFAT32 failed.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Formatting part1 exFAT ...");
|
||||
if (0 != FormatPart1exFAT(pPhyDrive->SizeInBytes))
|
||||
{
|
||||
Log("FormatPart1exFAT failed.");
|
||||
rc = 1;
|
||||
goto End;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);
|
||||
Log("Writing part2 FAT img ...");
|
||||
@@ -1867,21 +1956,34 @@ End:
|
||||
}
|
||||
}
|
||||
|
||||
if (GetVentoyFsType() > 0)
|
||||
if (state)
|
||||
{
|
||||
if (state)
|
||||
if (LargeFAT32)
|
||||
{
|
||||
Log("Reformat %C:\\ to %s", MountDrive, GetVentoyFsName());
|
||||
DISK_FormatVolume(MountDrive, GetVentoyFsType());
|
||||
Log("No need to reformat for large FAT32");
|
||||
pPhyDrive->VentoyFsClusterSize = GetVolumeClusterSize(MountDrive);
|
||||
}
|
||||
else if (DISK_FormatVolume(MountDrive, GetVentoyFsType(), Part1SectorCount * 512))
|
||||
{
|
||||
Log("Reformat %C:\\ to %s SUCCESS", MountDrive, GetVentoyFsName());
|
||||
pPhyDrive->VentoyFsClusterSize = GetVolumeClusterSize(MountDrive);
|
||||
|
||||
if ((GetVentoyFsType() != VTOY_FS_UDF) && (pPhyDrive->VentoyFsClusterSize < 2048))
|
||||
{
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
Log("### Invalid cluster size %d ###", pPhyDrive->VentoyFsClusterSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Can not reformat %s to %s", DriveName, GetVentoyFsName());
|
||||
Log("Reformat %C:\\ to %s FAILED", MountDrive, GetVentoyFsName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("No need to reformat ventoy partition");
|
||||
Log("Can not reformat %s to %s", DriveName, GetVentoyFsName());
|
||||
}
|
||||
|
||||
Log("OK\n");
|
||||
|
Reference in New Issue
Block a user