diff -r 43365a9b78a3 -r d8d70de2bd36 userlibandfileserver/fileserver/sfat32/sl_mnt.cpp --- a/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Tue Jul 06 15:50:07 2010 +0300 +++ b/userlibandfileserver/fileserver/sfat32/sl_mnt.cpp Wed Aug 18 11:08:29 2010 +0300 @@ -551,10 +551,8 @@ return; } - if(LockStatus() != 0) - {//-- can't finalise the volume if it has opened objects and not in the consistent state. - //-- Theoretically, we can finalise the mount if we have files opened only for read, but at present, - //-- it's impossible to detect such situation. + if(Locked()) + {//-- can't finalise the volume if it has opened disk access objects, like Format or RawAccess User::Leave(KErrInUse); } @@ -613,10 +611,23 @@ */ TBool CFatMountCB::VolCleanFlagSupported() const { - const TFatType fatType=FatType(); - - ASSERT(fatType == EFat12 || fatType == EFat16 || fatType == EFat32); - return (fatType != EFat12); + const TFatType fatType=FatType(); + + ASSERT(fatType == EFat12 || fatType == EFat16 || fatType == EFat32); + return (fatType != EFat12); + } + + +//----------------------------------------------------------------------------------------- +/** + @return Volume size in bytes according to the number of usable clusters. + This approach is not applicable to RAM drive, because its size isn't fixed and can be adjusted by the system. +*/ +TUint64 CFatMountCB::VolumeSizeInBytes() const + { + ASSERT(ConsistentState()); + ASSERT(!iRamDrive); + return ((TUint64)UsableClusters()) << ClusterSizeLog2(); } //----------------------------------------------------------------------------------------- @@ -681,16 +692,21 @@ const TUint32 freeClusters = FAT().NumberOfFreeClusters(bSyncOp); - + aVolume.iFree = (TInt64)freeClusters << ClusterSizeLog2(); __PRINT1(_L("CFatMountCB::VolumeL() free clusters:%d"), freeClusters); - aVolume.iFree = (TInt64)freeClusters << ClusterSizeLog2(); - - if (drvInfo.iType==EMediaRam) + + if(drvInfo.iType==EMediaRam) + {//-- a special case. RAM drive size is variable and adjustable. It should be calculated from aVolume.iFree and CMountCB::iFree + ASSERT(iRamDrive); aVolume.iSize=aVolume.iFree+iSize; - - aVolume.iSize-=ClusterBasePosition(); // Allow for bytes used by FAT etc - aVolume.iSize=(aVolume.iSize >> ClusterSizeLog2()) << ClusterSizeLog2(); //-- round down to cluster size + aVolume.iSize-=ClusterBasePosition(); // Allow for bytes used by FAT etc + aVolume.iSize=(aVolume.iSize >> ClusterSizeLog2()) << ClusterSizeLog2(); //-- round down to cluster size + } + else + {//-- normal case; the volume size is determined by amount of usable clusters + aVolume.iSize = VolumeSizeInBytes(); + } } @@ -4277,7 +4293,7 @@ TInt nRes; if(LockStatus()!=0) - { + {//-- can't run if the volume has opened objects, like files, directories, formats etc. __PRINT(_L("CFatMountCB::ScanDrive() locked!\n")); return KErrInUse; }