Changeset 298


Ignore:
Timestamp:
Jul 28, 2017, 12:30:00 AM (3 years ago)
Author:
Valery V. Sedletski
Message:

A fix for sectros per FAT < 3. Now it should work with 360 KB diskettes.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ifs/fat32a.c

    r297 r298  
    40554055{
    40564056ULONG  ulSec = ulSector * 3;
     4057USHORT usNumSec = 3;
    40574058USHORT rc;
    40584059
     
    40644065   // bytes blocks, so, it is needed to multiply by 3)
    40654066
     4067   // A 360 KB diskette has only 2 sectors per FAT
     4068   if (pVolInfo->BootSect.bpb.BigSectorsPerFat < 3)
     4069      {
     4070      if (ulSector > 0)
     4071         return ERROR_SECTOR_NOT_FOUND;
     4072      else
     4073         {
     4074         ulSec = 0;
     4075         usNumSec = pVolInfo->BootSect.bpb.BigSectorsPerFat;
     4076         }
     4077      }
     4078
    40664079   if (pVolInfo->ulCurFatSector == ulSector)
    40674080      return 0;
     
    40744087      }
    40754088
    4076    rc = ReadSector(pVolInfo, pVolInfo->ulActiveFatStart + ulSec, 3,
     4089   rc = ReadSector(pVolInfo, pVolInfo->ulActiveFatStart + ulSec, usNumSec,
    40774090      pVolInfo->pbFatSector, 0);
    40784091   if (rc)
     
    40904103{
    40914104ULONG  ulSec = ulSector * 3;
     4105USHORT usNumSec = 3;
    40924106USHORT usFat;
    40934107USHORT rc;
     
    41004114   // bytes blocks, so, it is needed to multiply by 3)
    41014115
     4116   // A 360 KB diskette has only 2 sectors per FAT
     4117   if (pVolInfo->BootSect.bpb.BigSectorsPerFat < 3)
     4118      {
     4119      if (ulSector > 0)
     4120         return ERROR_SECTOR_NOT_FOUND;
     4121      else
     4122         {
     4123         ulSec = 0;
     4124         usNumSec = pVolInfo->BootSect.bpb.BigSectorsPerFat;
     4125         }
     4126      }
     4127
    41024128   if (pVolInfo->ulCurFatSector != ulSector)
    41034129      {
     
    41164142   for (usFat = 0; usFat < pVolInfo->BootSect.bpb.NumberOfFATs; usFat++)
    41174143      {
    4118       rc = WriteSector(pVolInfo, pVolInfo->ulActiveFatStart + ulSec, 3,
     4144      rc = WriteSector(pVolInfo, pVolInfo->ulActiveFatStart + ulSec, usNumSec,
    41194145         pVolInfo->pbFatSector, 0);
    41204146      if (rc)
  • trunk/src/ifs/ifsfind.c

    r297 r298  
    235235      {
    236236      // FAT12/FAT16 root directory size (contiguous)
    237       ULONG ulRootDirSize = (ULONG)pVolInfo->BootSect.bpb.RootDirEntries * sizeof(DIRENTRY) /
     237      ULONG ulRootDirSize = ((ULONG)pVolInfo->BootSect.bpb.RootDirEntries * sizeof(DIRENTRY)) /
    238238         ((ULONG)pVolInfo->SectorsPerCluster * pVolInfo->BootSect.bpb.BytesPerSector);
    239       ulNumClusters = ((ULONG)pVolInfo->BootSect.bpb.RootDirEntries * sizeof(DIRENTRY) %
     239      ulNumClusters = (((ULONG)pVolInfo->BootSect.bpb.RootDirEntries * sizeof(DIRENTRY)) %
    240240         ((ULONG)pVolInfo->SectorsPerCluster * pVolInfo->BootSect.bpb.BytesPerSector)) ?
    241241         ulRootDirSize + 1 : ulRootDirSize;
     
    255255         {
    256256         ulNumClusters++;
    257          //ulCluster = GetNextCluster(pVolInfo, pFindInfo->pSHInfo, ulCluster);
    258          ulCluster = GetNextCluster(pVolInfo, NULL, ulCluster);
     257         ulCluster = GetNextCluster(pVolInfo, pFindInfo->pSHInfo, ulCluster);
     258         //ulCluster = GetNextCluster(pVolInfo, NULL, ulCluster);
    259259         }
    260260      }
     
    290290   pFindInfo->pInfo->ulBlockIndex = 0;
    291291   pFindInfo->pInfo->rgClusters[0] = ulDirCluster;
    292    pFindInfo->pInfo->ulTotalBlocks = (USHORT)ulNumBlocks; ////
     292   pFindInfo->pInfo->ulTotalBlocks = ulNumBlocks;
    293293   pFindInfo->pInfo->pDirEntries =
    294294      (PDIRENTRY)(&pFindInfo->pInfo->rgClusters[ulNumClusters]);
     
    19501950            {
    19511951            pFindInfo->pInfo->rgClusters[usIndex + 1] =
    1952                //GetNextCluster( pVolInfo, pFindInfo->pSHInfo, pFindInfo->pInfo->rgClusters[usIndex] );
    1953                GetNextCluster( pVolInfo, NULL, pFindInfo->pInfo->rgClusters[usIndex] );
     1952               GetNextCluster( pVolInfo, pFindInfo->pSHInfo, pFindInfo->pInfo->rgClusters[usIndex] );
     1953               //GetNextCluster( pVolInfo, NULL, pFindInfo->pInfo->rgClusters[usIndex] );
    19541954            }
    19551955
  • trunk/src/ifs/ifsmount.c

    r297 r298  
    516516            PBOOTSECT0 pSect0 = (PBOOTSECT0)pSect;
    517517            pVolInfo->ulStartOfData    = pSect0->bpb.ReservedSectors +
    518                pSect0->bpb.SectorsPerFat * pSect0->bpb.NumberOfFATs +
     518               (ULONG)pSect0->bpb.SectorsPerFat * pSect0->bpb.NumberOfFATs +
    519519               ((ULONG)pSect0->bpb.RootDirEntries * sizeof(DIRENTRY)) / pSect0->bpb.BytesPerSector +
    520520               ((((ULONG)pSect0->bpb.RootDirEntries * sizeof(DIRENTRY)) % pSect0->bpb.BytesPerSector) ? 1 : 0);
  • trunk/src/ufat32/chkdsk.c

    r297 r298  
    28222822{
    28232823ULONG  ulSec = ulSector * 3;
     2824USHORT usNumSec = 3;
    28242825ULONG rc;
    28252826
     
    28292830   // bytes blocks, so, it is needed to multiply by 3)
    28302831
     2832   // A 360 KB diskette has only 2 sectors per FAT
     2833   if (pCD->BootSect.bpb.BigSectorsPerFat < 3)
     2834      {
     2835      if (ulSector > 0)
     2836         return ERROR_SECTOR_NOT_FOUND;
     2837      else
     2838         {
     2839         ulSec = 0;
     2840         usNumSec = pCD->BootSect.bpb.BigSectorsPerFat;
     2841         }
     2842      }
     2843
    28312844   if (pCD->ulCurFATSector == ulSector)
    28322845      return TRUE;
    28332846
    2834    rc = ReadSector(pCD, pCD->ulActiveFatStart + ulSec, 3,
     2847   rc = ReadSector(pCD, pCD->ulActiveFatStart + ulSec, usNumSec,
    28352848      (PBYTE)pCD->pbFATSector);
    28362849   if (rc)
  • trunk/src/ufat32/fatfunc.c

    r289 r298  
    153153{
    154154   ULONG  ulSec = ulSector * 3;
     155   USHORT usNumSec = 3;
    155156   APIRET rc;
    156157
     
    160161   // bytes blocks, so, it is needed to multiply by 3)
    161162
     163   // A 360 KB diskette has only 2 sectors per FAT
     164   if (pCD->BootSect.bpb.BigSectorsPerFat < 3)
     165      {
     166      if (ulSector > 0)
     167         return ERROR_SECTOR_NOT_FOUND;
     168      else
     169         {
     170         ulSec = 0;
     171         usNumSec = pCD->BootSect.bpb.BigSectorsPerFat;
     172         }
     173      }
     174
    162175   if (pCD->ulCurFATSector == ulSector)
    163176      return 0;
     
    166179      return ERROR_SECTOR_NOT_FOUND;
    167180
    168    rc = ReadSector(pCD, pCD->ulActiveFatStart + ulSec, 3,
     181   rc = ReadSector(pCD, pCD->ulActiveFatStart + ulSec, usNumSec,
    169182      pCD->pbFATSector);
    170183   if (rc)
     
    183196   USHORT usFat;
    184197   ULONG  ulSec = ulSector * 3;
     198   USHORT usNumSec = 3;
    185199   APIRET rc;
    186200
     
    193207   // bytes blocks, so, it is needed to multiply by 3)
    194208
     209   // A 360 KB diskette has only 2 sectors per FAT
     210   if (pCD->BootSect.bpb.BigSectorsPerFat < 3)
     211      {
     212      if (ulSector > 0)
     213         return ERROR_SECTOR_NOT_FOUND;
     214      else
     215         {
     216         ulSec = 0;
     217         usNumSec = pCD->BootSect.bpb.BigSectorsPerFat;
     218         }
     219      }
     220
    195221   if (ulSec >= pCD->BootSect.bpb.BigSectorsPerFat)
    196222      return ERROR_SECTOR_NOT_FOUND;
     
    198224   for (usFat = 0; usFat < pCD->BootSect.bpb.NumberOfFATs; usFat++)
    199225      {
    200       rc = WriteSector(pCD, pCD->ulActiveFatStart + ulSec, 3,
     226      rc = WriteSector(pCD, pCD->ulActiveFatStart + ulSec, usNumSec,
    201227         pCD->pbFATSector);
    202228
Note: See TracChangeset for help on using the changeset viewer.