]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
fix issue #614
authorlongpanda <admin@ventoy.net>
Thu, 17 Dec 2020 08:11:17 +0000 (16:11 +0800)
committerlongpanda <admin@ventoy.net>
Thu, 17 Dec 2020 08:11:17 +0000 (16:11 +0800)
INSTALL/Ventoy2Disk.exe
Ventoy2Disk/Ventoy2Disk/PhyDrive.c
Ventoy2Disk/Ventoy2Disk/Utility.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.c
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.h
Ventoy2Disk/Ventoy2Disk/ff14/source/ff.c
Ventoy2Disk/Ventoy2Disk/ff14/source/ffconf.h

index 144fec91c85b07bb57608dc5c41c49643d93a83f..597dc3570e1604e69ccc3e57ab4dec5525b09080 100644 (file)
Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ
index 200a8cfd9db9dc7100957adb57adf086740ff44b..b863bb173585c1816386e48a4d60892d6690ad5d 100644 (file)
@@ -289,7 +289,7 @@ out:
 }\r
 \r
 \r
-static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)\r
+static DWORD GetVentoyVolumeName(int PhyDrive, UINT64 StartSectorId, CHAR *NameBuf, UINT32 BufLen, BOOL DelSlash)\r
 {\r
     size_t len;\r
     BOOL bRet;\r
@@ -304,7 +304,7 @@ static DWORD GetVentoyVolumeName(int PhyDrive, UINT32 StartSectorId, CHAR *NameB
 \r
     PartOffset = 512ULL * StartSectorId;\r
 \r
-       Log("GetVentoyVolumeName PhyDrive %d SectorStart:%u PartOffset:%llu", PhyDrive, StartSectorId, (ULONGLONG)PartOffset);\r
+       Log("GetVentoyVolumeName PhyDrive %d SectorStart:%llu PartOffset:%llu", PhyDrive, (ULONGLONG)StartSectorId, (ULONGLONG)PartOffset);\r
 \r
     hVolume = FindFirstVolumeA(VolumeName, sizeof(VolumeName));\r
     if (hVolume == INVALID_HANDLE_VALUE)\r
@@ -1401,18 +1401,18 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
         goto End;\r
     }\r
 \r
-    // clear first and last 1MB space\r
-    pTmpBuf = malloc(SIZE_1MB);\r
+    // clear first and last 2MB space\r
+    pTmpBuf = malloc(SIZE_2MB);\r
     if (!pTmpBuf)\r
     {\r
         Log("Failed to alloc memory.");\r
         rc = 1;\r
         goto End;\r
     }\r
-    memset(pTmpBuf, 0, SIZE_1MB);   \r
+    memset(pTmpBuf, 0, SIZE_2MB);\r
 \r
     SET_FILE_POS(512);\r
-    bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB - 512, &dwSize, NULL);\r
+    bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB - 512, &dwSize, NULL);\r
     Log("Write fisrt 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
     if (!bRet)\r
     {\r
@@ -1420,8 +1420,8 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
         goto End;\r
     }\r
 \r
-    SET_FILE_POS(SIZE_1MB);\r
-    bRet = WriteFile(hDrive, pTmpBuf, SIZE_1MB, &dwSize, NULL);\r
+    SET_FILE_POS(pPhyDrive->SizeInBytes - SIZE_2MB);\r
+    bRet = WriteFile(hDrive, pTmpBuf, SIZE_2MB, &dwSize, NULL);\r
     Log("Write 2nd 1MB ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
     if (!bRet)\r
     {\r
@@ -1430,30 +1430,71 @@ int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLett
     }\r
 \r
     SET_FILE_POS(0);\r
-    bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);\r
-    Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
-    if (!bRet)\r
+\r
+    if (pPhyDrive->SizeInBytes > 2199023255552ULL)\r
     {\r
-        rc = 1;\r
-        goto End;\r
-    }\r
+        VTOY_GPT_INFO *pGptInfo;\r
+        VTOY_GPT_HDR BackupHead;\r
+        LARGE_INTEGER liCurrentPosition;\r
 \r
-    //clear boot code and partition table (reserved disk signature)\r
-    memset(MBR.BootCode, 0, 440);\r
-    memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));\r
+        pGptInfo = (VTOY_GPT_INFO *)pTmpBuf;\r
 \r
-    VentoyFillLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);\r
+        VentoyFillWholeGpt(pPhyDrive->SizeInBytes, pGptInfo);\r
 \r
-    MBR.PartTbl[0].Active = 0x00; // bootable\r
-    MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS\r
+        SET_FILE_POS(pPhyDrive->SizeInBytes - 512);\r
+        VentoyFillBackupGptHead(pGptInfo, &BackupHead);\r
+        if (!WriteFile(hDrive, &BackupHead, sizeof(VTOY_GPT_HDR), &dwSize, NULL))\r
+        {\r
+            rc = 1;\r
+            Log("Write GPT Backup Head Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());\r
+            goto End;\r
+        }\r
 \r
-    SET_FILE_POS(0);\r
-    bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);\r
-    Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
-    if (!bRet)\r
+        SET_FILE_POS(pPhyDrive->SizeInBytes - 512 * 33);\r
+        if (!WriteFile(hDrive, pGptInfo->PartTbl, sizeof(pGptInfo->PartTbl), &dwSize, NULL))\r
+        {\r
+            rc = 1;\r
+            Log("Write GPT Backup Part Table Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());\r
+            goto End;\r
+        }\r
+\r
+        SET_FILE_POS(0);\r
+        if (!WriteFile(hDrive, pGptInfo, sizeof(VTOY_GPT_INFO), &dwSize, NULL))\r
+        {\r
+            rc = 1;\r
+            Log("Write GPT Info Failed, dwSize:%u (%u) ErrCode:%u", dwSize, sizeof(VTOY_GPT_INFO), GetLastError());\r
+            goto End;\r
+        }\r
+\r
+        Log("Write GPT Info OK ...");\r
+    }\r
+    else\r
     {\r
-        rc = 1;\r
-        goto End;\r
+        bRet = ReadFile(hDrive, &MBR, sizeof(MBR), &dwSize, NULL);\r
+        Log("Read MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
+        if (!bRet)\r
+        {\r
+            rc = 1;\r
+            goto End;\r
+        }\r
+\r
+        //clear boot code and partition table (reserved disk signature)\r
+        memset(MBR.BootCode, 0, 440);\r
+        memset(MBR.PartTbl, 0, sizeof(MBR.PartTbl));\r
+\r
+        VentoyFillMBRLocation(pPhyDrive->SizeInBytes, 2048, (UINT32)(pPhyDrive->SizeInBytes / 512 - 2048), MBR.PartTbl);\r
+\r
+        MBR.PartTbl[0].Active = 0x00; // bootable\r
+        MBR.PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS\r
+\r
+        SET_FILE_POS(0);\r
+        bRet = WriteFile(hDrive, &MBR, 512, &dwSize, NULL);\r
+        Log("Write MBR ret:%d size:%u err:%d", bRet, dwSize, LASTERR);\r
+        if (!bRet)\r
+        {\r
+            rc = 1;\r
+            goto End;\r
+        }\r
     }\r
 \r
     Log("Clear Ventoy successfully finished");\r
@@ -1490,7 +1531,7 @@ End:
         if (state != 1)\r
         {\r
             Log("need to mount ventoy part1...");\r
-            if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))\r
+            if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, 2048, DriveLetters, sizeof(DriveLetters), FALSE))\r
             {\r
                 DriveName[0] = MountDrive;\r
                 bRet = SetVolumeMountPointA(DriveName, DriveLetters);\r
@@ -1528,6 +1569,10 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
     CHAR DriveLetters[MAX_PATH] = { 0 };\r
     MBR_HEAD MBR;\r
     VTOY_GPT_INFO *pGptInfo = NULL;\r
+    UINT64 Part1StartSector = 0;\r
+    UINT64 Part1SectorCount = 0;\r
+    UINT64 Part2StartSector = 0;\r
+\r
 \r
     Log("InstallVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",\r
         PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,\r
@@ -1541,10 +1586,19 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
 \r
     PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);\r
 \r
-    VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);//also used to format 1st partition in GPT mode\r
     if (PartStyle)\r
     {\r
         VentoyFillGpt(pPhyDrive->SizeInBytes, pGptInfo);\r
+        Part1StartSector = pGptInfo->PartTbl[0].StartLBA;\r
+        Part1SectorCount = pGptInfo->PartTbl[0].LastLBA - Part1StartSector + 1;\r
+        Part2StartSector = pGptInfo->PartTbl[1].StartLBA;\r
+    }\r
+    else\r
+    {\r
+        VentoyFillMBR(pPhyDrive->SizeInBytes, &MBR, PartStyle);\r
+        Part1StartSector = MBR.PartTbl[0].StartSectorId;\r
+        Part1SectorCount = MBR.PartTbl[0].SectorCount;\r
+        Part2StartSector = MBR.PartTbl[1].StartSectorId;\r
     }\r
 \r
     Log("Lock disk for clean ............................. ");\r
@@ -1608,7 +1662,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
     //Refresh Drive Layout\r
     DeviceIoControl(hDrive, IOCTL_DISK_UPDATE_PROPERTIES, NULL, 0, NULL, 0, &dwSize, NULL);\r
 \r
-    disk_io_set_param(hDrive, MBR.PartTbl[0].StartSectorId + MBR.PartTbl[0].SectorCount);\r
+    disk_io_set_param(hDrive, Part1StartSector + Part1SectorCount);// include the 2048 sector gap\r
 \r
     PROGRESS_BAR_SET_POS(PT_FORMAT_PART1);\r
 \r
@@ -1626,9 +1680,12 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
         goto End;\r
     }\r
 \r
+    \r
+\r
     PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);\r
     Log("Writing part2 FAT img ...");\r
-    if (0 != FormatPart2Fat(hDrive, MBR.PartTbl[1].StartSectorId))\r
+    \r
+    if (0 != FormatPart2Fat(hDrive, Part2StartSector))\r
     {\r
         Log("FormatPart2Fat failed.");\r
         rc = 1;\r
@@ -1679,7 +1736,7 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
         }\r
 \r
         Log("Write GPT Info OK ...");\r
-        memcpy(&(pPhyDrive->MBR), &MBR, 512);\r
+        memcpy(&(pPhyDrive->MBR), &(pGptInfo->MBR), 512);\r
     }\r
     else\r
     {\r
@@ -1728,7 +1785,8 @@ End:
         if (state != 1)\r
         {\r
             Log("need to mount ventoy part1...");\r
-            if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, MBR.PartTbl[0].StartSectorId, DriveLetters, sizeof(DriveLetters), FALSE))\r
+            \r
+            if (0 == GetVentoyVolumeName(pPhyDrive->PhyDrive, Part1StartSector, DriveLetters, sizeof(DriveLetters), FALSE))\r
             {\r
                 DriveName[0] = MountDrive;\r
                 bRet = SetVolumeMountPointA(DriveName, DriveLetters);\r
@@ -1872,7 +1930,7 @@ int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive)
 \r
     Log("Lock volume for update .......................... ");\r
     hVolume = INVALID_HANDLE_VALUE;\r
-       Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, (UINT32)StartSector, DriveLetters, sizeof(DriveLetters), TRUE);\r
+       Status = GetVentoyVolumeName(pPhyDrive->PhyDrive, StartSector, DriveLetters, sizeof(DriveLetters), TRUE);\r
     if (ERROR_SUCCESS == Status)\r
     {\r
         Log("Now lock and dismount volume <%s>", DriveLetters);\r
index ff77db5564313299802d925a59dc3a706fc72442..91403bd297457c3b1aa57f0669f0cbc801208260 100644 (file)
@@ -382,7 +382,7 @@ BOOL IsVentoyLogicalDrive(CHAR DriveLetter)
 }\r
 \r
 \r
-int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)\r
+int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table)\r
 {\r
     BYTE Head;\r
     BYTE Sector;\r
@@ -473,7 +473,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
     //Part1\r
     PartStartSector = VENTOY_PART1_START_SECTOR;\r
        PartSectorCount = DiskSectorCount - ReservedSector - VENTOY_EFI_PART_SIZE / 512 - PartStartSector;\r
-    VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);\r
+    VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl);\r
 \r
     pMBR->PartTbl[0].Active = 0x80; // bootable\r
     pMBR->PartTbl[0].FsFlag = 0x07; // exFAT/NTFS/HPFS\r
@@ -481,7 +481,7 @@ int VentoyFillMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR, int PartStyle)
     //Part2\r
     PartStartSector += PartSectorCount;\r
     PartSectorCount = VENTOY_EFI_PART_SIZE / 512;\r
-    VentoyFillLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);\r
+    VentoyFillMBRLocation(DiskSizeBytes, PartStartSector, PartSectorCount, pMBR->PartTbl + 1);\r
 \r
     pMBR->PartTbl[1].Active = 0x00; \r
     pMBR->PartTbl[1].FsFlag = 0xEF; // EFI System Partition\r
@@ -538,6 +538,45 @@ static int VentoyFillProtectMBR(UINT64 DiskSizeBytes, MBR_HEAD *pMBR)
     return 0;\r
 }\r
 \r
+int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)\r
+{\r
+    UINT64 Part1SectorCount = 0;\r
+    UINT64 DiskSectorCount = DiskSizeBytes / 512;\r
+    VTOY_GPT_HDR *Head = &pInfo->Head;\r
+    VTOY_GPT_PART_TBL *Table = pInfo->PartTbl;\r
+    static GUID WindowsDataPartType = { 0xebd0a0a2, 0xb9e5, 0x4433, { 0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7 } };\r
+\r
+    VentoyFillProtectMBR(DiskSizeBytes, &pInfo->MBR);\r
+\r
+    Part1SectorCount = DiskSectorCount - 33 - 2048;\r
+\r
+    memcpy(Head->Signature, "EFI PART", 8);\r
+    Head->Version[2] = 0x01;\r
+    Head->Length = 92;\r
+    Head->Crc = 0;\r
+    Head->EfiStartLBA = 1;\r
+    Head->EfiBackupLBA = DiskSectorCount - 1;\r
+    Head->PartAreaStartLBA = 34;\r
+    Head->PartAreaEndLBA = DiskSectorCount - 34;\r
+    CoCreateGuid(&Head->DiskGuid);\r
+    Head->PartTblStartLBA = 2;\r
+    Head->PartTblTotNum = 128;\r
+    Head->PartTblEntryLen = 128;\r
+\r
+\r
+    memcpy(&(Table[0].PartType), &WindowsDataPartType, sizeof(GUID));\r
+    CoCreateGuid(&(Table[0].PartGuid));\r
+    Table[0].StartLBA = 2048;\r
+    Table[0].LastLBA = 2048 + Part1SectorCount - 1;\r
+    Table[0].Attr = 0;\r
+    memcpy(Table[0].Name, L"Data", 4 * 2);\r
+\r
+    //Update CRC\r
+    Head->PartTblCrc = VentoyCrc32(Table, sizeof(pInfo->PartTbl));\r
+    Head->Crc = VentoyCrc32(Head, Head->Length);\r
+\r
+    return 0;\r
+}\r
 \r
 int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)\r
 {\r
index 5fe037bb395e05dd877c616d7a4719e145698c3f..1f206aaa28d33416e155dd478572787c8356f372 100644 (file)
@@ -153,6 +153,8 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
                }\r
 \r
                *Part2StartSector = pGpt->PartTbl[1].StartLBA;\r
+\r
+        memcpy(pMBR, &(pGpt->MBR), sizeof(MBR_HEAD));\r
        }\r
        else\r
        {\r
@@ -188,9 +190,10 @@ static BOOL IsVentoyPhyDrive(int PhyDrive, UINT64 SizeBytes, MBR_HEAD *pMBR, UIN
                }\r
 \r
                *Part2StartSector = MBR.PartTbl[1].StartSectorId;\r
+\r
+        memcpy(pMBR, &MBR, sizeof(MBR_HEAD));\r
        }\r
 \r
-       memcpy(pMBR, &MBR, sizeof(MBR_HEAD));\r
     Log("PhysicalDrive%d is ventoy disk", PhyDrive);\r
     return TRUE;\r
 }\r
index 0f8e76c6eaec201cc7ad82c62dc4b02df3399384..8407ae1420c4c4d0cf38b4c8c2c902c4e154a558 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdio.h>\r
 \r
 #define SIZE_1MB                    (1024 * 1024)\r
+#define SIZE_2MB                    (2048 * 1024)\r
 #define VENTOY_EFI_PART_SIZE       (32 * SIZE_1MB)\r
 #define VENTOY_PART1_START_SECTOR    2048\r
 \r
@@ -208,6 +209,7 @@ int ParseCmdLineOption(LPSTR lpCmdLine);
 int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);\r
 int UpdateVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive);\r
 int VentoyFillBackupGptHead(VTOY_GPT_INFO *pInfo, VTOY_GPT_HDR *pHead);\r
+int VentoyFillWholeGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo);\r
 void SetProgressBarPos(int Pos);\r
 int ReadWholeFileToBuf(const CHAR *FileName, int ExtLen, void **Bufer, int *BufLen);\r
 int INIT unxz(unsigned char *in, int in_size,\r
@@ -219,7 +221,7 @@ void disk_io_set_param(HANDLE Handle, UINT64 SectorCount);
 INT_PTR CALLBACK PartDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);\r
 int GetReservedSpaceInMB(void);\r
 int FindProcessOccupyDisk(HANDLE hDrive, PHY_DRIVE_INFO *pPhyDrive);\r
-int VentoyFillLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);\r
+int VentoyFillMBRLocation(UINT64 DiskSizeInBytes, UINT32 StartSectorId, UINT32 SectorCount, PART_TABLE *Table);\r
 int ClearVentoyFromPhyDrive(HWND hWnd, PHY_DRIVE_INFO *pPhyDrive, char *pDrvLetter);\r
 UINT32 VentoyCrc32(void *Buffer, UINT32 Length);\r
 \r
index 22cbac5c0bdfc44896d6a48acb40d178b8ddfa58..c39bea6f26f47566de138c9b52583b30439aefed 100644 (file)
@@ -475,9 +475,9 @@ static const char* const VolumeStr[FF_VOLUMES] = {FF_VOLUME_STRS};  /* Pre-define
 #endif
 
 #if FF_LBA64
-#if FF_MIN_GPT > 0x100000000
-#error Wrong FF_MIN_GPT setting
-#endif
+//#if FF_MIN_GPT > 0x100000000
+//#error Wrong FF_MIN_GPT setting
+//#endif
 static const BYTE GUID_MS_Basic[16] = {0xA2,0xA0,0xD0,0xEB,0xE5,0xB9,0x33,0x44,0x87,0xC0,0x68,0xB6,0xB7,0x26,0x99,0xC7};
 #endif
 
@@ -5983,10 +5983,10 @@ FRESULT f_mkfs (
                        if (sz_vol >= 0x4000000) sz_au = 256;   /* >= 64Ms */
                }
                b_fat = b_vol + 32;                                                                             /* FAT start at offset 32 */
-               sz_fat = (DWORD)((sz_vol / sz_au + 2) * 4 + ss - 1) / ss;       /* Number of FAT sectors */
+               sz_fat = (DWORD)(((sz_vol / sz_au + 2) * 4 + ss - 1) / ss);     /* Number of FAT sectors */
                b_data = (b_fat + sz_fat + sz_blk - 1) & ~((LBA_t)sz_blk - 1);  /* Align data area to the erase block boundary */
                if (b_data - b_vol >= sz_vol / 2) LEAVE_MKFS(FR_MKFS_ABORTED);  /* Too small volume? */
-               n_clst = (DWORD)(sz_vol - (b_data - b_vol)) / sz_au;    /* Number of clusters */
+               n_clst = (DWORD)((sz_vol - (b_data - b_vol)) / sz_au);  /* Number of clusters */
                if (n_clst <16) LEAVE_MKFS(FR_MKFS_ABORTED);                    /* Too few clusters? */
                if (n_clst > MAX_EXFAT) LEAVE_MKFS(FR_MKFS_ABORTED);    /* Too many clusters? */
 
index 229d865ac89e0f5ce9f32f328bf14c93524a70e4..d40f86968032e0665abd065a296d7bfb528d215a 100644 (file)
 /  To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
 
 
-#define FF_MIN_GPT             0x100000000
+#define FF_MIN_GPT             0x10000000000000
 /* Minimum number of sectors to switch GPT format to create partition in f_mkfs and
 /  f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */