userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 42 a179b74831c9
child 44 3e88ff8f41d5
--- a/userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp	Thu Aug 19 11:14:22 2010 +0300
+++ b/userlibandfileserver/fileserver/sfat32/sl_mnt32.cpp	Tue Aug 31 16:34:26 2010 +0300
@@ -218,8 +218,8 @@
 void CFatMountCB::SetVolumeCleanL(TBool aClean) 
     {
 
-	//-- The volume can't be set clean if there are objects opened on it. This precondition must be checked before calling this function
-    if(aClean && LockStatus()!=0)
+	//-- 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
+    if(aClean && Locked())
         {
         __PRINT1(_L("#- CFatMountCB::SetVolumeCleanL drive:%d isn't free!"),DriveNumber());
         ASSERT(0);
@@ -892,8 +892,12 @@
     if(aLevel == EMountVolParamQuery)
         {
         ASSERT(ConsistentState()); //-- volume state shall be consistent, otherwise its parameters do not make sense
-		if(iRamDrive)
-			return KErrNotSupported; //-- it requires knowledge of free space on the volume
+
+		// Ram Drives calculate their total / free space based on querying HAL parameters
+		// in ::VolumeL(). To make all interfaces return consistent results, we need to force
+		// a fallback to that for RAM drives.
+		if (iRamDrive)
+			return (KErrNotSupported);
 
         switch(aOption)
             {
@@ -931,12 +935,7 @@
             case ESQ_MountedVolumeSize:
                 {
                 TUint64* pVal = (TUint64*)aParam; 
-                *pVal = iSize; //-- physical drive size
-
-                //-- take into account space occupied by FAT table, etc.
-                *pVal -= ClusterBasePosition(); 
-                *pVal=(*pVal >> ClusterSizeLog2()) << ClusterSizeLog2();  //-- round down to cluster size
-
+                *pVal = VolumeSizeInBytes();
                 __PRINT1(_L("MountControl() MountedVolumeSize:%LU"), *pVal);
                 return KErrNone;
                 }
@@ -1068,7 +1067,7 @@
 			//  Read the remaining length or the entire cluster block whichever is smaller
 			TInt readLength = (TInt)Min((TInt64)(aLength-readTotal),(clusterListLen<<ClusterSizeLog2())-pos);
 			__ASSERT_DEBUG(readLength>0,Fault(EReadFileSectionFailed));
-			TInt64 dataAddress=(FAT().DataPositionInBytesL(cluster))+pos;
+			TInt64 dataAddress=(FAT().DataPositionInBytes(cluster))+pos;
 			iRawDisk->ReadL(dataAddress,readLength,aTrg,aMessage,readTotal, 0);
 			readTotal += readLength;