Changeset 289
- Timestamp:
- Jul 6, 2017, 9:53:56 AM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/ifs/fat32a.c ¶
r287 r289 6031 6031 pNew1->u.File.ulLastModifiedTimestp.month = pGI->month; 6032 6032 pNew1->u.File.ulLastModifiedTimestp.day = pGI->day; 6033 pNew1->u.File.ulLastModifiedTimestp.hour = pGI-> day;6033 pNew1->u.File.ulLastModifiedTimestp.hour = pGI->hour; 6034 6034 pNew1->u.File.ulLastModifiedTimestp.minutes = pGI->minutes; 6035 6035 pNew1->u.File.ulLastModifiedTimestp.seconds = pGI->seconds; -
TabularUnified trunk/src/ifs/ifsfile.c ¶
r286 r289 1249 1249 PBYTE pbCluster; 1250 1250 ULONG ulClusterSector; 1251 U SHORT usClusterOffset;1251 ULONG ulClusterOffset; 1252 1252 USHORT usBlockOffset; 1253 1253 ULONG ulBytesPerCluster; … … 1518 1518 ulBytesPerBlock = pVolInfo->ulBlockSize; 1519 1519 #ifdef INCL_LONGLONG 1520 u sClusterOffset = (USHORT)(pos % ulBytesPerCluster); /* get remainder */1520 ulClusterOffset = (ULONG)(pos % ulBytesPerCluster); /* get remainder */ 1521 1521 usBlockOffset = (USHORT)(pos % ulBytesPerBlock); /* get remainder */ 1522 1522 #else … … 1525 1525 1526 1526 llRes = iModUL(pos, ulBytesPerCluster); 1527 u sClusterOffset = (USHORT)llRes.ulLo;1527 ulClusterOffset = (ULONG)llRes.ulLo; 1528 1528 llRes = iModUL(pos, ulBytesPerBlock); 1529 1529 usBlockOffset = (USHORT)llRes.ulLo; … … 1589 1589 } 1590 1590 1591 if ( ((ULONG)usClusterOffset + ulCurrBytesToRead)>= ulBytesPerCluster)1591 if (ulClusterOffset + ulCurrBytesToRead >= ulBytesPerCluster) 1592 1592 { 1593 1593 pOpenInfo->ulCurCluster = GetNextCluster(pVolInfo, pOpenInfo->pSHInfo, pOpenInfo->ulCurCluster); … … 1870 1870 PBYTE pbCluster; 1871 1871 ULONG ulClusterSector; 1872 U SHORT usClusterOffset;1872 ULONG ulClusterOffset; 1873 1873 USHORT usBlockOffset; 1874 1874 ULONG ulBytesPerCluster; … … 2299 2299 ulBytesPerBlock = pVolInfo->ulBlockSize; 2300 2300 #ifdef INCL_LONGLONG 2301 u sClusterOffset = (USHORT)(pos % ulBytesPerCluster); /* get remainder */2301 ulClusterOffset = (ULONG)(pos % ulBytesPerCluster); /* get remainder */ 2302 2302 usBlockOffset = (USHORT)(pos % ulBytesPerBlock); /* get remainder */ 2303 2303 #else … … 2306 2306 2307 2307 llRes = iModUL(pos, ulBytesPerCluster); 2308 u sClusterOffset = (USHORT)llRes.ulLo;2308 ulClusterOffset = (ULONG)llRes.ulLo; 2309 2309 llRes = iModUL(pos, ulBytesPerBlock); 2310 2310 usBlockOffset = (USHORT)llRes.ulLo; … … 2376 2376 } 2377 2377 2378 if ( ((ULONG)usClusterOffset + ulCurrBytesToWrite)>= ulBytesPerCluster)2378 if (ulClusterOffset + ulCurrBytesToWrite >= ulBytesPerCluster) 2379 2379 { 2380 2380 pOpenInfo->ulCurCluster = GetNextCluster(pVolInfo, pOpenInfo->pSHInfo, pOpenInfo->ulCurCluster); -
TabularUnified trunk/src/include/fat32c.h ¶
r282 r289 259 259 ULONG query_vol_label(char *path, char *pszVolLabel, int cbVolLabel); 260 260 void set_datetime(DIRENTRY *pDir); 261 void set_datetime1(DIRENTRY1 *pDir); 261 262 char *get_error(USHORT rc); 262 263 void query_current_disk(char *pszDrive); -
TabularUnified trunk/src/ufat32/fatfunc.c ¶
r286 r289 94 94 95 95 void set_datetime(DIRENTRY *pDir); 96 void set_datetime1(DIRENTRY1 *pDir); 96 97 97 98 /****************************************************************** … … 1675 1676 return ERROR_FILE_EXISTS; 1676 1677 } 1678 set_datetime1(&DirNew); 1677 1679 memcpy(pNew, &DirNew, sizeof (DIRENTRY)); 1678 1680 … … 1843 1845 // Message(" Updating cluster"); 1844 1846 memcpy(pWorkFile, pNew, sizeof (DIRENTRY1)); 1847 set_datetime1(pWorkFile); 1845 1848 if (pStreamNew) 1846 1849 { … … 3363 3366 memcpy(DirEntry.bExtention, szFileName + 6, 3); 3364 3367 3365 set_datetime(&DirEntry); 3368 3369 #ifdef EXFAT 3370 if (pCD->bFatType < FAT_TYPE_EXFAT) 3371 #endif 3372 set_datetime(&DirEntry); 3373 #ifdef EXFAT 3374 else 3375 set_datetime1((PDIRENTRY1)&DirEntry); 3376 #endif 3377 3366 3378 if (!ulDirCluster) 3367 3379 ulDirCluster = MakeDir(pCD, pCD->BootSect.bpb.RootDirStrtClus, &DirEntry, szFileName); … … 3402 3414 strncpy(pData, szFileName, cbData); 3403 3415 3404 set_datetime(&DirEntry); 3416 #ifdef EXFAT 3417 if (pCD->bFatType < FAT_TYPE_EXFAT) 3418 #endif 3419 set_datetime(&DirEntry); 3420 #ifdef EXFAT 3421 else 3422 set_datetime1((PDIRENTRY1)&DirEntry); 3423 #endif 3405 3424 3406 3425 #ifdef EXFAT … … 3455 3474 PDIRENTRY pNew, PDIRENTRY1 pNewStream, PSZ pszName) 3456 3475 { 3476 #ifdef EXFAT 3477 if (pCD->bFatType < FAT_TYPE_EXFAT) 3478 { 3479 #endif 3480 set_datetime(pNew); 3481 #ifdef EXFAT 3482 } 3483 else 3484 { 3485 set_datetime1((PDIRENTRY1)pNew); 3486 } 3487 #endif 3488 3457 3489 return ModifyDirectory(pCD, ulDirCluster, pDirSHInfo, MODIFY_DIR_INSERT, 3458 3490 NULL, pNew, NULL, pNewStream, pszName); -
TabularUnified trunk/src/ufat32/format.c ¶
r288 r289 196 196 #ifdef EXFAT 197 197 case FAT_TYPE_EXFAT: 198 // 7 MB to 256 MB - 4 KB 199 if ( DiskSizeMB > 7 ) 198 // 256 MB to 512 MB - 1 KB 199 if ( DiskSizeMB > 256 ) 200 ret = get_spc( 1, BytesPerSect ); // ret = 0x2; 201 202 // 512 MB to 1,024 MB - 2 KB 203 if ( DiskSizeMB > 512 ) 204 ret = get_spc( 2, BytesPerSect ); // ret = 0x4; 205 206 // 1,024 MB to 2,048 MB - 4 KB 207 if ( DiskSizeMB > 1024 ) 200 208 ret = get_spc( 4, BytesPerSect ); // ret = 0x8; 201 209 202 // 256 MB to 1,024 MB - 32 KB 203 if ( DiskSizeMB > 256 ) 210 // 2,048 MB to 4,096 MB - 8 KB 211 if ( DiskSizeMB > 2048 ) 212 ret = get_spc( 8, BytesPerSect ); // ret = 0x10; 213 214 // 4,096 MB to 8,192 MB - 16 KB 215 if ( DiskSizeMB > 4096 ) 216 ret = get_spc( 16, BytesPerSect ); // ret = 0x20; 217 218 // 8,192 MB to 16,384 MB - 32 KB 219 if ( DiskSizeMB > 8192 ) 204 220 ret = get_spc( 32, BytesPerSect ); // ret = 0x40; 221 222 // 16,384 MB to 32,768 MB - 64 KB 223 if ( DiskSizeMB > 16384 ) 224 ret = get_spc( 64, BytesPerSect ); // ret = 0x80; 205 225 206 226 // Larger than 32,784 MB - 128 KB 207 227 if ( DiskSizeMB > 32784 ) 208 ret = get_spc( 128, BytesPerSect ); // ret = 0x 80;228 ret = get_spc( 128, BytesPerSect ); // ret = 0x100; 209 229 #endif 210 230 } … … 382 402 FAT_FSINFO *pFAT32FsInfo; 383 403 DWORD *pFirstSectOfFat; 404 DWORD FatSize; 384 405 385 406 #ifdef EXFAT … … 466 487 dp.SectorsPerCluster = get_sectors_per_cluster( params, ((LONGLONG)dp.TotalSectors) * dp.BytesPerSect, dp.BytesPerSect ); 467 488 468 dp.FatSize = get_fat_size_sectors ( params, dp.TotalSectors,469 dp.ReservedSectCount, dp.SectorsPerCluster,489 FatSize = get_fat_size_sectors ( params, dp.TotalSectors, 490 dp.ReservedSectCount, params->sectors_per_cluster, 470 491 dp.NumFATs, dp.BytesPerSect ); 471 492 472 UserAreaSize = dp.TotalSectors - dp.ReservedSectCount - ( dp.NumFATs*dp.FatSize);493 UserAreaSize = dp.TotalSectors - dp.ReservedSectCount - ((DWORD)dp.NumFATs*FatSize); 473 494 474 495 if (params->bFatType < FAT_TYPE_FAT32) 475 496 // root dir is excluded from user area on FAT12/FAT16 476 UserAreaSize -= dp.SectorsPerCluster;477 478 ClusterCount = UserAreaSize / dp.SectorsPerCluster;497 UserAreaSize -= params->sectors_per_cluster; // ???! 498 499 ClusterCount = UserAreaSize / params->sectors_per_cluster; 479 500 480 501 if ( (ClusterCount >= FAT12_BAD_CLUSTER && params->bFatType == FAT_TYPE_FAT12) || … … 542 563 FatNeeded /= dp.BytesPerSect; 543 564 544 if ( FatNeeded > dp.FatSize )565 if ( FatNeeded > FatSize ) 545 566 { 546 567 die ( "This drive is too big for this version\n" … … 606 627 pFATBootSect->wBytsPerSec = (WORD) dp.BytesPerSect; 607 628 608 pFATBootSect->bSecPerClus = (BYTE) dp.SectorsPerCluster;629 pFATBootSect->bSecPerClus = (BYTE) params->sectors_per_cluster; 609 630 pFATBootSect->wRsvdSecCnt = (WORD) dp.ReservedSectCount; 610 631 pFATBootSect->bNumFATs = (BYTE) dp.NumFATs; 611 pFATBootSect->wRootEntCnt = ( dp.SectorsPerCluster * dp.BytesPerSect) /632 pFATBootSect->wRootEntCnt = (params->sectors_per_cluster * dp.BytesPerSect) / 612 633 sizeof(DIRENTRY); // number of dir entries per cluster 613 634 … … 618 639 619 640 pFATBootSect->bMedia = 0xF8; 620 pFATBootSect->wFATSz16 = dp.FatSize;641 pFATBootSect->wFATSz16 = (WORD)FatSize; 621 642 pFATBootSect->wSecPerTrk = (WORD) dp.SectorsPerTrack; 622 643 pFATBootSect->wNumHeads = (WORD) dp.TracksPerCylinder; … … 653 674 pFAT32BootSect->wBytsPerSec = (WORD) dp.BytesPerSect; 654 675 655 pFAT32BootSect->bSecPerClus = (BYTE) dp.SectorsPerCluster;676 pFAT32BootSect->bSecPerClus = (BYTE) params->sectors_per_cluster; 656 677 pFAT32BootSect->wRsvdSecCnt = (WORD) dp.ReservedSectCount; 657 678 pFAT32BootSect->bNumFATs = (BYTE) dp.NumFATs; … … 666 687 pFAT32BootSect->dTotSec32 = dp.TotalSectors; 667 688 668 pFAT32BootSect->dFATSz32 = dp.FatSize;689 pFAT32BootSect->dFATSz32 = (WORD)FatSize; 669 690 pFAT32BootSect->wExtFlags = 0; 670 691 pFAT32BootSect->wFSVer = 0; … … 687 708 { 688 709 USHORT usSectorSize = (USHORT)dp.BytesPerSect; 689 USHORT usClusterSize = (USHORT) dp.SectorsPerCluster;710 USHORT usClusterSize = (USHORT)params->sectors_per_cluster; 690 711 691 712 // fill out the boot sector and fs info … … 698 719 pEXFATBootSect->ullVolumeLength = (ULONGLONG)dp.TotalSectors; 699 720 pEXFATBootSect->ulFatOffset = (WORD) dp.ReservedSectCount; 700 pEXFATBootSect->ulFatLength = dp.FatSize;721 pEXFATBootSect->ulFatLength = FatSize; 701 722 pEXFATBootSect->ulClusterHeapOffset = pEXFATBootSect->ulFatOffset + pEXFATBootSect->ulFatLength; 702 pEXFATBootSect->ulClusterCount = (ULONG)((dp.TotalSectors - dp.FatSize703 - dp.ReservedSectCount) / dp.SectorsPerCluster);723 pEXFATBootSect->ulClusterCount = (ULONG)((dp.TotalSectors - FatSize 724 - dp.ReservedSectCount) / params->sectors_per_cluster); 704 725 ulExfatBitmapLen = (pEXFATBootSect->ulClusterCount / 8) + 705 726 (pEXFATBootSect->ulClusterCount % 8 ? 1 : 0); 706 ulExfatBitmapClusters = ulExfatBitmapLen / ( dp.SectorsPerCluster * dp.BytesPerSect);707 ulExfatBitmapClusters = (ulExfatBitmapLen % ( dp.SectorsPerCluster * dp.BytesPerSect)) ?727 ulExfatBitmapClusters = ulExfatBitmapLen / (params->sectors_per_cluster * dp.BytesPerSect); 728 ulExfatBitmapClusters = (ulExfatBitmapLen % (params->sectors_per_cluster * dp.BytesPerSect)) ? 708 729 ulExfatBitmapClusters + 1 : ulExfatBitmapClusters; 709 730 ulExfatUpCaseLen = sizeof(pUpCase); 710 ulExfatUpCaseClusters = ulExfatUpCaseLen / ( dp.SectorsPerCluster * dp.BytesPerSect);711 ulExfatUpCaseClusters = (ulExfatUpCaseLen % ( dp.SectorsPerCluster * dp.BytesPerSect)) ?731 ulExfatUpCaseClusters = ulExfatUpCaseLen / (params->sectors_per_cluster * dp.BytesPerSect); 732 ulExfatUpCaseClusters = (ulExfatUpCaseLen % (params->sectors_per_cluster * dp.BytesPerSect)) ? 712 733 ulExfatUpCaseClusters + 1 : ulExfatUpCaseClusters; 713 734 pEXFATBootSect->RootDirStrtClus = 2 + ulExfatBitmapClusters + ulExfatUpCaseClusters; … … 741 762 pEXFATBootSect->usBootSig = 0xaa55; 742 763 743 mem_alloc ( (void **)&pBitmap, ulExfatBitmapClusters * dp.SectorsPerCluster * dp.BytesPerSect);764 mem_alloc ( (void **)&pBitmap, ulExfatBitmapClusters * params->sectors_per_cluster * dp.BytesPerSect); 744 765 745 766 if ( !pBitmap ) 746 767 die ( "Failed to allocate memory", -2 ); 747 768 748 mem_alloc ( (void **)&pRootDir, dp.SectorsPerCluster * dp.BytesPerSect);769 mem_alloc ( (void **)&pRootDir, params->sectors_per_cluster * dp.BytesPerSect); 749 770 750 771 if ( !pRootDir ) 751 772 die ( "Failed to allocate memory", -2 ); 752 773 753 mem_alloc ( (void **)&pUpCaseTbl, ulExfatUpCaseClusters * dp.SectorsPerCluster * dp.BytesPerSect);774 mem_alloc ( (void **)&pUpCaseTbl, ulExfatUpCaseClusters * params->sectors_per_cluster * dp.BytesPerSect); 754 775 755 776 if ( !pRootDir ) … … 797 818 pFirstSectOfFat[2] = 0x0fffffff; // end of cluster chain for root dir 798 819 } 799 #ifdef EXFAT800 else if (params->bFatType == FAT_TYPE_EXFAT)801 {802 pFirstSectOfFat[0] = 0xfffffff8; // Reserved cluster 1 media id in low byte803 pFirstSectOfFat[1] = 0xffffffff; // Reserved cluster 2 EOC804 805 for (i = 0; i < ulExfatBitmapClusters - 1; i++)806 {807 // next cluster for alloc bitmap808 pFirstSectOfFat[2 + i] = 3 + i;809 }810 // end of cluster chain for alloc bitmap811 pFirstSectOfFat[2 + i++] = 0xffffffff;812 813 for (i = 0; i < ulExfatUpCaseClusters - 1; i++)814 {815 // next cluster for upcase table816 pFirstSectOfFat[2 + ulExfatBitmapClusters + i] = 3 + ulExfatBitmapClusters + i;817 }818 // end of cluster chain for upcase table819 pFirstSectOfFat[2 + ulExfatBitmapClusters + i++] = 0xffffffff;820 821 // root dir822 pFirstSectOfFat[2 + ulExfatBitmapClusters + i++] = 0xffffffff;823 }824 #endif825 820 826 821 // Write boot sector, fats … … 842 837 // Now we're commited - print some info first 843 838 show_message ( "Size: %g MB %u sectors.\n", 0, 0, 2, (double) ((dp.TotalSectors / (1024*1024)) * dp.BytesPerSect), dp.TotalSectors ); 844 show_message ( "%d Bytes Per Sector, Cluster size %d bytes.\n", 0, 0, 2, dp.BytesPerSect, dp.SectorsPerCluster * dp.BytesPerSect );839 show_message ( "%d Bytes Per Sector, Cluster size %d bytes.\n", 0, 0, 2, dp.BytesPerSect, params->sectors_per_cluster * dp.BytesPerSect ); 845 840 846 841 show_message ( "Volume label is %1.\n", 0, 1375, 1, TYPE_STRING, vol ); … … 848 843 show_message ( "The Volume Serial Number is %1.\n", 0, 1243, 1, TYPE_STRING, szString); 849 844 850 show_message ( "%d Reserved Sectors, % d Sectors per FAT, %d fats.\n", 0, 0, 3, dp.ReservedSectCount, dp.FatSize, dp.NumFATs );845 show_message ( "%d Reserved Sectors, %lu Sectors per FAT, %d fats.\n", 0, 0, 3, dp.ReservedSectCount, FatSize, dp.NumFATs ); 851 846 852 847 // Work out the Cluster count … … 856 851 857 852 // fix up the FSInfo sector 858 pFAT32FsInfo->dFree_Count = (UserAreaSize/ dp.SectorsPerCluster)-1;853 pFAT32FsInfo->dFree_Count = (UserAreaSize/params->sectors_per_cluster)-1; 859 854 pFAT32FsInfo->dNxt_Free = 3; // clusters 0-1 resered, we used cluster 2 for the root dir 860 855 861 sprintf(szString, "%lu", (pFAT32FsInfo->dFree_Count / 1024) * ( dp.SectorsPerCluster * dp.BytesPerSect));856 sprintf(szString, "%lu", (pFAT32FsInfo->dFree_Count / 1024) * (params->sectors_per_cluster * dp.BytesPerSect)); 862 857 show_message ( "%1 kilobytes are available.\n", 0, 537, 1, TYPE_STRING, szString); 863 858 … … 870 865 871 866 // First zero out ReservedSect + FatSize * NumFats + SectorsPerCluster 872 SystemAreaSize = (dp.ReservedSectCount+( dp.NumFATs*dp.FatSize) + dp.SectorsPerCluster);867 SystemAreaSize = (dp.ReservedSectCount+((DWORD)dp.NumFATs*FatSize) + params->sectors_per_cluster); 873 868 874 869 #ifdef EXFAT … … 935 930 #endif 936 931 937 // Write the first fat sector in the right places 938 for ( i=0; i<dp.NumFATs; i++ ) 939 { 940 int SectorStart = dp.ReservedSectCount + (i * dp.FatSize ); 941 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pFirstSectOfFat, 1 ); 942 } 932 #ifdef EXFAT 933 if (params->bFatType < FAT_TYPE_EXFAT) 934 { 935 #endif 936 // Write the first fat sector in the right places 937 for ( i = 0; i < dp.NumFATs; i++ ) 938 { 939 int SectorStart = dp.ReservedSectCount + (i * FatSize ); 940 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pFirstSectOfFat, 1 ); 941 } 942 #ifdef EXFAT 943 } 944 else 945 { 946 int j; 947 948 for ( j = 0; j < dp.NumFATs; j++ ) 949 { 950 int SectorStart = dp.ReservedSectCount + (j * FatSize); 951 int EntriesPerSec = dp.BytesPerSect / 4; 952 953 pFirstSectOfFat[0] = 0xfffffff8; // Reserved cluster 1 media id in low byte 954 pFirstSectOfFat[1] = 0xffffffff; // Reserved cluster 2 EOC 955 956 for (i = 2; i < ulExfatBitmapClusters + 2; i++) 957 { 958 if (!(i % EntriesPerSec)) 959 { 960 // next sector 961 if (i / EntriesPerSec) 962 { 963 // write previous sector 964 write_sect ( hDevice, 965 SectorStart + (i / EntriesPerSec - 1), 966 dp.BytesPerSect, 967 pFirstSectOfFat, 968 1 ); 969 } 970 memset(pFirstSectOfFat, 0, dp.BytesPerSect); 971 } 972 973 if (i == ulExfatBitmapClusters + 1) 974 { 975 // end of cluster chain for alloc bitmap 976 pFirstSectOfFat[i % EntriesPerSec] = 0xffffffff; 977 } 978 else 979 // next cluster for alloc bitmap 980 pFirstSectOfFat[i % EntriesPerSec] = i + 1; 981 } 982 983 for (i = 0; i < ulExfatUpCaseClusters; i++) 984 { 985 int k = 2 + ulExfatBitmapClusters + i; 986 987 if (!(k % EntriesPerSec)) 988 { 989 // next sector 990 if (k / EntriesPerSec) 991 { 992 write_sect ( hDevice, 993 SectorStart + (k / EntriesPerSec - 1), 994 dp.BytesPerSect, 995 pFirstSectOfFat, 996 1 ); 997 } 998 memset(pFirstSectOfFat, 0, dp.BytesPerSect); 999 } 1000 1001 if (i == ulExfatUpCaseClusters - 1) 1002 { 1003 // end of cluster chain for alloc bitmap 1004 pFirstSectOfFat[k % EntriesPerSec] = 0xffffffff; 1005 } 1006 else 1007 // next cluster for alloc bitmap 1008 pFirstSectOfFat[k % EntriesPerSec] = k + 1; 1009 } 1010 1011 // root dir 1012 pFirstSectOfFat[(2 + ulExfatBitmapClusters + ulExfatUpCaseClusters) % EntriesPerSec] = 0xffffffff; 1013 1014 // write last sector 1015 write_sect ( hDevice, 1016 SectorStart + ((2 + ulExfatBitmapClusters + ulExfatUpCaseClusters) / EntriesPerSec), 1017 dp.BytesPerSect, 1018 pFirstSectOfFat, 1019 1 ); 1020 } 1021 } 1022 #endif 943 1023 944 1024 #ifdef EXFAT … … 950 1030 951 1031 // write bitmap 952 memset( pBitmap, 0, ulExfatBitmapClusters * dp.SectorsPerCluster * dp.BytesPerSect );1032 memset( pBitmap, 0, ulExfatBitmapClusters * params->sectors_per_cluster * dp.BytesPerSect ); 953 1033 // bitmap clusters 954 1034 for ( i = 0; i < ulExfatBitmapClusters; i++) … … 963 1043 // root dir cluster 964 1044 SetBmpEntry2(pBitmap, &dp, 2 + ulExfatBitmapClusters + i, 1); 965 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pBitmap, ulExfatBitmapClusters * dp.SectorsPerCluster );1045 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pBitmap, ulExfatBitmapClusters * params->sectors_per_cluster ); 966 1046 967 1047 // write upcase table 968 memset( pUpCaseTbl, 0, ulExfatUpCaseClusters * dp.SectorsPerCluster * dp.BytesPerSect );1048 memset( pUpCaseTbl, 0, ulExfatUpCaseClusters * params->sectors_per_cluster * dp.BytesPerSect ); 969 1049 memcpy( pUpCaseTbl, pUpCase, ulExfatUpCaseLen ); 970 SectorStart += ulExfatBitmapClusters * dp.SectorsPerCluster;971 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pUpCaseTbl, ulExfatUpCaseClusters * dp.SectorsPerCluster );1050 SectorStart += ulExfatBitmapClusters * params->sectors_per_cluster; 1051 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pUpCaseTbl, ulExfatUpCaseClusters * params->sectors_per_cluster ); 972 1052 973 1053 // write root dir 974 memset( pRootDir, 0, dp.SectorsPerCluster * dp.BytesPerSect );1054 memset( pRootDir, 0, params->sectors_per_cluster * dp.BytesPerSect ); 975 1055 // volume label 976 1056 pDir->bEntryType = ENTRY_TYPE_VOLUME_LABEL; … … 989 1069 pDir->u.UpCaseTbl.ulTblCheckSum = GetChkSum2((char *)pUpCase, ulExfatUpCaseLen); 990 1070 // 991 SectorStart += ulExfatUpCaseClusters * dp.SectorsPerCluster;992 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pRootDir, dp.SectorsPerCluster );1071 SectorStart += ulExfatUpCaseClusters * params->sectors_per_cluster; 1072 write_sect ( hDevice, SectorStart, dp.BytesPerSect, pRootDir, params->sectors_per_cluster ); 993 1073 } 994 1074 #endif … … 1056 1136 { 1057 1137 mem_free ( (void *)pEXFATBootSect, dp.BytesPerSect ); 1058 mem_free ( (void *)pBitmap, dp.SectorsPerCluster * dp.BytesPerSect );1059 mem_free ( (void *)pRootDir, dp.SectorsPerCluster * dp.BytesPerSect );1138 mem_free ( (void *)pBitmap, params->sectors_per_cluster * dp.BytesPerSect ); 1139 mem_free ( (void *)pRootDir, params->sectors_per_cluster * dp.BytesPerSect ); 1060 1140 } 1061 1141 #endif … … 1247 1327 case 'C': 1248 1328 p.sectors_per_cluster = atol(val); 1249 if ( (p.sectors_per_cluster != 1) && // 512 bytes, 0.5k 1250 (p.sectors_per_cluster != 2) && // 1K 1251 (p.sectors_per_cluster != 4) && // 2K 1252 (p.sectors_per_cluster != 8) && // 4K 1253 (p.sectors_per_cluster != 16) && // 8K 1254 (p.sectors_per_cluster != 32) && // 16K 1255 (p.sectors_per_cluster != 64) && // 32K 1256 (p.sectors_per_cluster != 128) // 64K ( Microsoft say don't use 64K or bigger); 1257 ) 1258 { 1259 show_message ( "Ignoring bad cluster size %d\n", 0, 0, 1, p.sectors_per_cluster ); 1260 p.sectors_per_cluster = 0; 1261 usage( argv[0] ); 1262 } 1329 if (p.bFatType < FAT_TYPE_EXFAT) 1330 { 1331 if ( (p.sectors_per_cluster != 1) && // 512 bytes, 0.5k 1332 (p.sectors_per_cluster != 2) && // 1K 1333 (p.sectors_per_cluster != 4) && // 2K 1334 (p.sectors_per_cluster != 8) && // 4K 1335 (p.sectors_per_cluster != 16) && // 8K 1336 (p.sectors_per_cluster != 32) && // 16K 1337 (p.sectors_per_cluster != 64) && // 32K 1338 (p.sectors_per_cluster != 128) // 64K ( Microsoft say don't use 64K or bigger); 1339 ) 1340 { 1341 show_message ( "Ignoring bad cluster size %d\n", 0, 0, 1, p.sectors_per_cluster ); 1342 p.sectors_per_cluster = 0; 1343 usage( argv[0] ); 1344 } 1345 } 1263 1346 continue; 1264 1347 case 'R': -
TabularUnified trunk/src/ufat32/os2.c ¶
r282 r289 678 678 void set_datetime(DIRENTRY *pDir) 679 679 { 680 // FAT12/FAT16/FAT32 680 681 DATETIME datetime; 681 682 … … 692 693 pDir->wCreateTime = pDir->wLastWriteTime; 693 694 pDir->wAccessDate = pDir->wLastWriteDate; 695 } 696 697 void set_datetime1(DIRENTRY1 *pDir) 698 { 699 // exFAT 700 DATETIME datetime; 701 702 DosGetDateTime(&datetime); 703 704 pDir->u.File.ulLastModifiedTimestp.year = datetime.year - 1980; 705 pDir->u.File.ulLastModifiedTimestp.month = datetime.month; 706 pDir->u.File.ulLastModifiedTimestp.day = datetime.day; 707 pDir->u.File.ulLastModifiedTimestp.hour = datetime.hours; 708 pDir->u.File.ulLastModifiedTimestp.minutes = datetime.minutes; 709 pDir->u.File.ulLastModifiedTimestp.seconds = datetime.seconds; 710 711 pDir->u.File.ulCreateTimestp = pDir->u.File.ulLastModifiedTimestp; 712 pDir->u.File.ulLastAccessedTimestp = pDir->u.File.ulLastModifiedTimestp; 694 713 } 695 714 -
TabularUnified trunk/src/ufat32/win32.c ¶
r282 r289 378 378 void set_datetime(DIRENTRY *pDir) 379 379 { 380 // FAT12/FAT16/FAT32 380 381 SYSTEMTIME datetime; 381 382 … … 394 395 } 395 396 397 398 void set_datetime1(DIRENTRY1 *pDir) 399 { 400 // exFAT 401 SYSTEMTIME datetime; 402 403 GetSystemTime(&datetime); 404 405 pDir->u.File.ulLastModifiedTimestp.year = datetime.wYear - 1980; 406 pDir->u.File.ulLastModifiedTimestp.month = datetime.wMonth; 407 pDir->u.File.ulLastModifiedTimestp.day = datetime.wDay; 408 pDir->u.File.ulLastModifiedTimestp.hour = datetime.wHour; 409 pDir->u.File.ulLastModifiedTimestp.minutes = datetime.wMinute; 410 pDir->u.File.ulLastModifiedTimestp.seconds = datetime.wSecond / 2; 411 412 pDir->u.File.ulCreateTimestp = pDir->u.File.ulLastModifiedTimestp; 413 pDir->u.File.ulLastAccessedTimestp = pDir->u.File.ulLastModifiedTimestp; 414 } 396 415 397 416 char *get_error(USHORT rc)
Note:
See TracChangeset
for help on using the changeset viewer.