userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
child 268 345b1ca54e88
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
   216 @leave  if write error occured.        
   216 @leave  if write error occured.        
   217 */
   217 */
   218 void CFatMountCB::SetVolumeCleanL(TBool aClean) 
   218 void CFatMountCB::SetVolumeCleanL(TBool aClean) 
   219     {
   219     {
   220 
   220 
   221 	//-- The volume can't be set clean if there are disk access objects opened on it. This precondition must be checked before calling this function
   221 	//-- The volume can't be set clean if there are objects opened on it. This precondition must be checked before calling this function
   222     if(aClean && Locked())
   222     if(aClean && LockStatus()!=0)
   223         {
   223         {
   224         __PRINT1(_L("#- CFatMountCB::SetVolumeCleanL drive:%d isn't free!"),DriveNumber());
   224         __PRINT1(_L("#- CFatMountCB::SetVolumeCleanL drive:%d isn't free!"),DriveNumber());
   225         ASSERT(0);
   225         ASSERT(0);
   226         User::Leave(KErrInUse);
   226         User::Leave(KErrInUse);
   227         return;
   227         return;
   890 
   890 
   891     //-- mount-specific volume parameters queries that might not be handled by CFatMountCB::VolumeL
   891     //-- mount-specific volume parameters queries that might not be handled by CFatMountCB::VolumeL
   892     if(aLevel == EMountVolParamQuery)
   892     if(aLevel == EMountVolParamQuery)
   893         {
   893         {
   894         ASSERT(ConsistentState()); //-- volume state shall be consistent, otherwise its parameters do not make sense
   894         ASSERT(ConsistentState()); //-- volume state shall be consistent, otherwise its parameters do not make sense
   895 
   895 		if(iRamDrive)
   896 		// Ram Drives calculate their total / free space based on querying HAL parameters
   896 			return KErrNotSupported; //-- it requires knowledge of free space on the volume
   897 		// in ::VolumeL(). To make all interfaces return consistent results, we need to force
       
   898 		// a fallback to that for RAM drives.
       
   899 		if (iRamDrive)
       
   900 			return (KErrNotSupported);
       
   901 
   897 
   902         switch(aOption)
   898         switch(aOption)
   903             {
   899             {
   904             //-- Request a certain amount of free space on the volume.
   900             //-- Request a certain amount of free space on the volume.
   905             case ESQ_RequestFreeSpace:
   901             case ESQ_RequestFreeSpace:
   933         
   929         
   934             //-- A request to obtain size of the mounted volume without blocking (CMountCB::VolumeL() can block).
   930             //-- A request to obtain size of the mounted volume without blocking (CMountCB::VolumeL() can block).
   935             case ESQ_MountedVolumeSize:
   931             case ESQ_MountedVolumeSize:
   936                 {
   932                 {
   937                 TUint64* pVal = (TUint64*)aParam; 
   933                 TUint64* pVal = (TUint64*)aParam; 
   938                 *pVal = VolumeSizeInBytes();
   934                 *pVal = iSize; //-- physical drive size
       
   935 
       
   936                 //-- take into account space occupied by FAT table, etc.
       
   937                 *pVal -= ClusterBasePosition(); 
       
   938                 *pVal=(*pVal >> ClusterSizeLog2()) << ClusterSizeLog2();  //-- round down to cluster size
       
   939 
   939                 __PRINT1(_L("MountControl() MountedVolumeSize:%LU"), *pVal);
   940                 __PRINT1(_L("MountControl() MountedVolumeSize:%LU"), *pVal);
   940                 return KErrNone;
   941                 return KErrNone;
   941                 }
   942                 }
   942 
   943 
   943             default:
   944             default:
  1065         if (pos<(clusterListLen<<ClusterSizeLog2()))
  1066         if (pos<(clusterListLen<<ClusterSizeLog2()))
  1066             {
  1067             {
  1067 			//  Read the remaining length or the entire cluster block whichever is smaller
  1068 			//  Read the remaining length or the entire cluster block whichever is smaller
  1068 			TInt readLength = (TInt)Min((TInt64)(aLength-readTotal),(clusterListLen<<ClusterSizeLog2())-pos);
  1069 			TInt readLength = (TInt)Min((TInt64)(aLength-readTotal),(clusterListLen<<ClusterSizeLog2())-pos);
  1069 			__ASSERT_DEBUG(readLength>0,Fault(EReadFileSectionFailed));
  1070 			__ASSERT_DEBUG(readLength>0,Fault(EReadFileSectionFailed));
  1070 			TInt64 dataAddress=(FAT().DataPositionInBytes(cluster))+pos;
  1071 			TInt64 dataAddress=(FAT().DataPositionInBytesL(cluster))+pos;
  1071 			iRawDisk->ReadL(dataAddress,readLength,aTrg,aMessage,readTotal, 0);
  1072 			iRawDisk->ReadL(dataAddress,readLength,aTrg,aMessage,readTotal, 0);
  1072 			readTotal += readLength;
  1073 			readTotal += readLength;
  1073 
  1074 
  1074 			if (readTotal == aLength)
  1075 			if (readTotal == aLength)
  1075 				return;
  1076 				return;