os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_drv.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat/sl_drv.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,610 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32\sfat\sl_drv.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.22 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.23 +//!!
    1.24 +//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
    1.25 +//!!
    1.26 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.27 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    1.28 +
    1.29 +
    1.30 +#include "sl_std.h"
    1.31 +#include "sl_cache.h"
    1.32 +
    1.33 +const TInt KMaxRecoverableRetries=10;
    1.34 +const TInt KMaxCriticalRetries=10;
    1.35 +
    1.36 +
    1.37 +//---------------------------------------------------------------------------------------------------------------------------------------
    1.38 +
    1.39 +
    1.40 +TFatDriveInterface::TFatDriveInterface() 
    1.41 +                   :iMount(NULL)
    1.42 +{
    1.43 +}
    1.44 +
    1.45 +/**
    1.46 +    Initialise the interface object.
    1.47 +    @param  aMount the CFatMountCB that owns this object
    1.48 +*/
    1.49 +TBool TFatDriveInterface::Init(CFatMountCB* aMount)
    1.50 +{
    1.51 +    ASSERT(aMount);
    1.52 +    iMount = aMount;
    1.53 +    aMount->LocalDrive()->SetMount(aMount);
    1.54 +    return iProxyDrive.Init(aMount->LocalDrive());
    1.55 +}
    1.56 +
    1.57 +/**
    1.58 +    pseudo-destructor. 
    1.59 +*/
    1.60 +void TFatDriveInterface::Close()
    1.61 +{
    1.62 +     if(iMount)
    1.63 +        iMount->LocalDrive()->SetMount(NULL);
    1.64 +     iMount = NULL;
    1.65 +}
    1.66 +
    1.67 +//---------------------------------------------------------------------------------------------------------------------------------------
    1.68 +
    1.69 +/**
    1.70 +    Read data from the media via CProxyDrive interface.
    1.71 +    This is non-critical read: on error Non-critical notifier is involved
    1.72 +
    1.73 +    @param  aPos        absolute media position
    1.74 +    @param  aLength     how many bytes to read
    1.75 +    @param  aTrg        data descriptor
    1.76 +
    1.77 +    @return KErrNone - success
    1.78 +    @return KErrNotReady - non-critical error
    1.79 +    @return KErrCorrupt - an illegal write is detected
    1.80 +    @return KErrBadPower - failure due to low power
    1.81 +
    1.82 +*/
    1.83 +TInt TFatDriveInterface::ReadNonCritical(TInt64 aPos, TInt aLength, TDes8& aTrg) const
    1.84 +{
    1.85 +    TInt nRes = KErrNone;
    1.86 +    TInt cntRetry = KMaxRecoverableRetries;
    1.87 +
    1.88 +    //__PRINT2(_L("#=+++ Read_nc1: pos:%LU, len:%u"), aPos, aLength);
    1.89 +
    1.90 +    for(;;)
    1.91 +    {
    1.92 +        nRes = iProxyDrive.Read(aPos,aLength,aTrg);
    1.93 +        if (nRes==KErrNone)
    1.94 +            break;
    1.95 +
    1.96 +        __PRINT4(_L("TFatDriveInterface::ReadNonCritical() failure! drv:%d Posl=%LU len=%d retval=%d"), iMount->DriveNumber(), aPos, aLength, nRes);
    1.97 +        
    1.98 +        if(--cntRetry <= 0)
    1.99 +        {
   1.100 +            nRes = KErrCorrupt;
   1.101 +            break;
   1.102 +        }
   1.103 +
   1.104 +        nRes = HandleRecoverableError(nRes);
   1.105 +        if (nRes !=ERetry)
   1.106 +            break;
   1.107 +    }
   1.108 +
   1.109 +    return nRes;
   1.110 +}
   1.111 +
   1.112 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.113 +
   1.114 +/**
   1.115 +    Read data from the media via CProxyDrive interface. 
   1.116 +    This is non-critical read: on error Non-critical notifier is involved
   1.117 +
   1.118 +    @param  aPos        absolute media position
   1.119 +    @param  aLength     how many bytes to read
   1.120 +    @param  aTrg        data descriptor
   1.121 +    @param  aMessage
   1.122 +    @param  anOffset
   1.123 +
   1.124 +    @return KErrNone - success
   1.125 +    @return KErrNotReady - non-critical error
   1.126 +    @return KErrCorrupt - an illegal write is detected
   1.127 +    @return KErrBadPower - failure due to low power
   1.128 +
   1.129 +*/
   1.130 +TInt TFatDriveInterface::ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   1.131 +{
   1.132 +    //__PRINT2(_L("#=+++ Read_nc2: pos:%LU, len:%u"), aPos, aLength);
   1.133 +
   1.134 +    TInt nRes = KErrNone;
   1.135 +    TInt cntRetry = KMaxRecoverableRetries;
   1.136 +
   1.137 +    for(;;)
   1.138 +    {
   1.139 +        nRes = iProxyDrive.Read(aPos, aLength, aTrg, aMessage, anOffset);
   1.140 +        if (nRes==KErrNone)
   1.141 +            break;
   1.142 +
   1.143 +        __PRINT4(_L("TFatDriveInterface::ReadNonCritical() Failure! drv:%d aPosl=%d len=%d anOffset=%d"), iMount->DriveNumber(), aPos,aLength, anOffset);
   1.144 +        
   1.145 +        if(--cntRetry <= 0)
   1.146 +        {
   1.147 +            nRes = KErrCorrupt;
   1.148 +            break;
   1.149 +        }
   1.150 +
   1.151 +        nRes = HandleRecoverableError(nRes);
   1.152 +        if (nRes !=ERetry)
   1.153 +            break;
   1.154 +    }
   1.155 +
   1.156 +    return nRes;
   1.157 +}
   1.158 +
   1.159 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.160 +
   1.161 +/**
   1.162 +    Read data from the media via CProxyDrive interface with a critical notifier.
   1.163 +    This method shall be used to read critical filesystem data, such as directory entries, FAT data.
   1.164 +
   1.165 +    @param  aPos        absolute media position
   1.166 +    @param  aLength     how many bytes to read
   1.167 +    @param  aTrg        data descriptor
   1.168 +
   1.169 +    @return KErrNone - success
   1.170 +    @return KErrNotReady - non-critical error
   1.171 +    @return KErrCorrupt - an illegal write is detected
   1.172 +    @return KErrAbort - user aborted read
   1.173 +*/
   1.174 +TInt TFatDriveInterface::ReadCritical(TInt64 aPos,TInt aLength,TDes8& aTrg) const
   1.175 +{
   1.176 +    //__PRINT2(_L("#=+++ Read_C: pos:%LU, len:%u"), aPos, aLength);
   1.177 +
   1.178 +    TInt nRes = KErrNone;
   1.179 +
   1.180 +    for(;;)
   1.181 +    {
   1.182 +        nRes = iProxyDrive.Read(aPos, aLength, aTrg);
   1.183 +        if(nRes == KErrNone)
   1.184 +            break;
   1.185 +
   1.186 +        __PRINT4(_L("TFatDriveInterface::ReadCritical() Error! drv:%d Posl=%LU len=%d retval=%d"), iMount->DriveNumber(), aPos, aLength, nRes);
   1.187 +        
   1.188 +        nRes=HandleCriticalError(nRes);
   1.189 +        if (nRes != ERetry)
   1.190 +            break;
   1.191 +    }
   1.192 +
   1.193 +    return nRes;
   1.194 +}
   1.195 +
   1.196 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.197 +
   1.198 +/**
   1.199 +    Write data to the media via CProxyDrive interface.
   1.200 +    
   1.201 +    @param  aPos        absolute media position
   1.202 +    @param  aLength     how many bytes to write
   1.203 +    @param  aSrc        pointer to the data 
   1.204 +    @param  aMessage
   1.205 +    @param  anOffset
   1.206 +    
   1.207 +    @return KErrNone - success
   1.208 +    @return KErrNotReady - non-critical error
   1.209 +    @return KErrBadPower - write not attempted due to low batteries
   1.210 +    @return KErrCorrupt - an illegal write is detected
   1.211 +    @return KErrAccessDenied - write to protected media
   1.212 +*/
   1.213 +TInt TFatDriveInterface::WriteNonCritical(TInt64 aPos, TInt aLength, const TAny* aSrc, const RMessagePtr2 &aMessage, TInt anOffset)
   1.214 +{
   1.215 +    //__PRINT2(_L("#=+++ Write_NC: pos:%LU, len:%u"), aPos, aLength);
   1.216 +
   1.217 +    
   1.218 +    TInt nRes = KErrNone;
   1.219 +    TInt cntRetry = KMaxRecoverableRetries;
   1.220 +
   1.221 +    for(;;)
   1.222 +    {
   1.223 +        iMount->OpenMountForWrite(); //-- make a callback to CFatMountCB to perform some actions on 1st write.
   1.224 +        nRes = iProxyDrive.Write(aPos, aLength, aSrc, aMessage, anOffset);
   1.225 +        if (nRes==KErrNone)
   1.226 +            break;
   1.227 +
   1.228 +        __PRINT4(_L("TFatDriveInterface::WriteNonCritical() failure! drv:%d, Pos=%LU len=%d anOffset=%d"), iMount->DriveNumber(), aPos, aLength, anOffset);
   1.229 +        
   1.230 +        if(--cntRetry <= 0)
   1.231 +        {
   1.232 +            nRes = KErrCorrupt;
   1.233 +            break;
   1.234 +        }
   1.235 +
   1.236 +        nRes = HandleRecoverableError(nRes);
   1.237 +        if (nRes !=ERetry)
   1.238 +            break;
   1.239 +    }
   1.240 +
   1.241 +
   1.242 +    return nRes;
   1.243 +}
   1.244 +
   1.245 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.246 +
   1.247 +/**
   1.248 +    Write data to the media via CProxyDrive interface. On error this method can invoke a critical notifier.
   1.249 +    This method is intended to be called for the filesstem critical data, i.e. FAT metadata, such as directory entries,
   1.250 +    FAT table etc.
   1.251 +    
   1.252 +    @param  aPos  absolute media position
   1.253 +    @param  aSrc  descriptor with the source data
   1.254 +    
   1.255 +    @return KErrNone - success
   1.256 +    @return KErrNotReady - non-critical error
   1.257 +    @return KErrBadPower - write not attempted due to low batteries
   1.258 +    @return KErrCorrupt - an illegal write is detected
   1.259 +    @return KErrAccessDenied - write to protected media
   1.260 +*/
   1.261 +TInt TFatDriveInterface::WriteCritical(TInt64 aPos, const TDesC8& aSrc)
   1.262 +{
   1.263 +    //__PRINT2(_L("#=+++ Write_C: pos:%LU, len:%u"), aPos, aSrc.Length());
   1.264 +
   1.265 +    TInt nRes = KErrNone;
   1.266 +
   1.267 +#ifdef _DEBUG
   1.268 +    
   1.269 +    TBool simulatedWriteFailure = EFalse; //-- if true it means that the write failure has been simulated
   1.270 +
   1.271 +    //-- debug interface to simulate write failure
   1.272 +    if(iMount->IsWriteFail())
   1.273 +    {
   1.274 +        if(iMount->WriteFailCount() != 0)
   1.275 +        {
   1.276 +            iMount->DecWriteFailCount();
   1.277 +        }
   1.278 +        else
   1.279 +        {//-- simulate write failure
   1.280 +            if(iMount->WriteFailError()==-99)
   1.281 +                UserSvr::ResetMachine(EStartupWarmReset);
   1.282 +            else
   1.283 +            {
   1.284 +                //-- invalidate caches, because actual write to the drive isn't going to happen
   1.285 +                if(iMount->RawDisk().DirCacheInterface())
   1.286 +                    iMount->RawDisk().DirCacheInterface()->InvalidateCache();
   1.287 +
   1.288 +                iMount->SetWriteFail(EFalse);
   1.289 +                
   1.290 +                TRAP_IGNORE(iMount->RawDisk().InvalidateUidCache()); //-- invalidate whole UID data cache
   1.291 +                TRAP_IGNORE(iMount->FAT().InvalidateCacheL());       //-- invalidate whole FAT cache
   1.292 +                
   1.293 +                iMount->InvalidateLeafDirCache();
   1.294 +
   1.295 +                nRes = iMount->WriteFailError(); 
   1.296 +                simulatedWriteFailure = ETrue; //-- won't perform actual write later
   1.297 +                __PRINT4(_L("TFatDriveInterface::WriteCritical() Simulating write failure. drv:%d, aPos=%LU len=%d Code=%d"), iMount->DriveNumber(), aPos,aSrc.Length(),nRes);
   1.298 +
   1.299 +            }
   1.300 +        }
   1.301 +    }//if(iMount->IsWriteFail())
   1.302 +
   1.303 +    if(!simulatedWriteFailure)
   1.304 +#endif // _DEBUG
   1.305 +    {
   1.306 +        //-- try to write data until success or user gives up
   1.307 +        for(;;)
   1.308 +        {
   1.309 +            for(TInt i=0; i<KMaxCriticalRetries; i++)
   1.310 +            {
   1.311 +                iMount->OpenMountForWrite();  //-- make a callback to CFatMountCB to perform some actions on 1st write.
   1.312 +                nRes=iProxyDrive.Write(aPos,aSrc);
   1.313 +                if (nRes==KErrNone)
   1.314 +                    return nRes;
   1.315 +            }
   1.316 +
   1.317 +            //-- write error occured
   1.318 +            __PRINT4(_L("TFatDriveInterface::WriteCritical() failure! drv:%d, aPos=%LU len=%d retval=%d"), iMount->DriveNumber(), aPos,aSrc.Length(),nRes);
   1.319 +
   1.320 +            nRes=HandleCriticalError(nRes);
   1.321 +            if (nRes!=ERetry)
   1.322 +                break;
   1.323 +
   1.324 +        }//for(;;)
   1.325 +    
   1.326 +    }// if(!simulatedWriteFailure)
   1.327 +    
   1.328 +    return nRes;
   1.329 +}
   1.330 +
   1.331 +
   1.332 +/**
   1.333 +    Get Last Error Info from the proxy drive
   1.334 +        
   1.335 +    @param  aErrorInfo data descriptor for the error info.
   1.336 +    @return KErrNone - success, interrogate aErrorInfo for further info
   1.337 +    @return KErrNotSupported - media driver does not support
   1.338 +*/
   1.339 +TInt TFatDriveInterface::GetLastErrorInfo(TDes8& aErrorInfo) const
   1.340 +{
   1.341 +    return iProxyDrive.GetLastErrorInfo(aErrorInfo);
   1.342 +}
   1.343 +
   1.344 +
   1.345 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.346 +
   1.347 +/**
   1.348 +    Handle critical error
   1.349 +
   1.350 +    @param aResult result from the media driver (error code)
   1.351 +
   1.352 +    @return ERetry - Attempt operation again
   1.353 +    @return KErrAbort - User aborted notifier
   1.354 +    @return KErrAccessDenied - media is read only
   1.355 +    @return KErrCorrupt - cf-card is corrupt
   1.356 +*/
   1.357 +TInt TFatDriveInterface::HandleCriticalError(TInt aResult) const
   1.358 +    {
   1.359 +    __PRINT2(_L("TFatDriveInterface::HandleCriticalError drv:%d, code:%d"), iMount->DriveNumber(),aResult);
   1.360 +
   1.361 +    TLocaleMessage line1;
   1.362 +    TLocaleMessage line2;
   1.363 +
   1.364 +    TInt r=KErrAbort;
   1.365 +
   1.366 +    if (aResult==KErrLocked)
   1.367 +    {
   1.368 +        r=KErrLocked;
   1.369 +        goto End;
   1.370 +    }
   1.371 +
   1.372 +    if (aResult==KErrAccessDenied)
   1.373 +        {
   1.374 +        r=KErrAccessDenied;
   1.375 +        goto End;
   1.376 +        }
   1.377 +    
   1.378 +    if (aResult==KErrArgument || aResult==KErrBadDescriptor)
   1.379 +        {
   1.380 +        r=KErrCorrupt;
   1.381 +        goto End;
   1.382 +        }
   1.383 +
   1.384 +    if (iMount->Drive().IsChanged())
   1.385 +        {//-- check if the media we accessing is the same as it used to be
   1.386 +          if(iMount->CheckVolumeTheSame())
   1.387 +            {//-- the media is the same
   1.388 +            if(!IsDriveWriteProtected())
   1.389 +                {
   1.390 +                iMount->Drive().SetChanged(EFalse);
   1.391 +                r=ERetry;
   1.392 +                goto End;
   1.393 +                }
   1.394 +            }
   1.395 +        }
   1.396 +
   1.397 +    if (aResult==KErrAbort && !iMount->Drive().IsChanged())
   1.398 +        {
   1.399 +        r=ERetry;
   1.400 +        goto End;
   1.401 +        }
   1.402 +
   1.403 +    if (aResult==KErrBadPower)
   1.404 +        {
   1.405 +        line1=EFileServer_LowPowerLine1;
   1.406 +        line2=EFileServer_LowPowerLine2;
   1.407 +        }
   1.408 +    else if (iMount->Drive().IsChanged())
   1.409 +        {
   1.410 +        line1=EFileServer_PutTheCardBackLine1;
   1.411 +        line2=EFileServer_PutTheCardBackLine2;
   1.412 +        }
   1.413 +    else
   1.414 +        {
   1.415 +        line1=EFileServer_DiskErrorLine1;
   1.416 +        line2=EFileServer_DiskErrorLine2;
   1.417 +        }
   1.418 +    
   1.419 +    if (NotifyUser())
   1.420 +        {
   1.421 +        FOREVER
   1.422 +            {
   1.423 +            TInt buttonVal;
   1.424 +            TInt ret=iMount->Notifier()->Notify(TLocaleMessageText(line1),
   1.425 +                                                TLocaleMessageText(line2),
   1.426 +                                                TLocaleMessageText(EFileServer_Button1),
   1.427 +                                                TLocaleMessageText(EFileServer_Button2),
   1.428 +                                                buttonVal);
   1.429 +            if (ret!=KErrNone)
   1.430 +                break; 
   1.431 +            if (buttonVal!=1)
   1.432 +                break; // Abort
   1.433 +
   1.434 +            if (iMount->Drive().IsChanged())
   1.435 +                {
   1.436 +//
   1.437 +// Without this code, retry will indiscriminately write over whatever disk happens to be present.
   1.438 +// However if the write error is to the bootsector remounting will always fail because the boot
   1.439 +// sector will have changed and hence the disk is useless.
   1.440 +// 
   1.441 +                if(!iMount->CheckVolumeTheSame())
   1.442 +                    continue; //-- the media isn't the same as originally mounted; continue asking
   1.443 +
   1.444 +                if(IsDriveWriteProtected())
   1.445 +                    continue; //-- still can not write to the drive
   1.446 +
   1.447 +
   1.448 +                iMount->Drive().SetChanged(EFalse);
   1.449 +                }
   1.450 +
   1.451 +            r=ERetry; // Retry
   1.452 +            break;
   1.453 +            }
   1.454 +        }
   1.455 +End:
   1.456 +    return(r);
   1.457 +    }
   1.458 +
   1.459 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.460 +
   1.461 +/**
   1.462 +    Handle recoverable error
   1.463 +
   1.464 +    @param aResult result from the media driver (error code)
   1.465 +
   1.466 +    @return ERetry - retry write
   1.467 +    @return KErrCorrupt - media is corrupt
   1.468 +    @return KErrBadPower - low power failure
   1.469 +    @return KErrNotReady - non-critical error
   1.470 +*/
   1.471 +TInt TFatDriveInterface::HandleRecoverableError(TInt aResult) const
   1.472 +    {
   1.473 +    __PRINT2(_L("TFatDriveInterface::HandleRecoverableError drv:%d, code:%d"), iMount->DriveNumber(),aResult);
   1.474 +
   1.475 +    if (aResult==KErrAccessDenied)
   1.476 +        return(KErrAccessDenied);
   1.477 +    if (aResult == KErrLocked)
   1.478 +        return KErrLocked;
   1.479 +    if (aResult==KErrArgument || aResult==KErrBadDescriptor)
   1.480 +        return(KErrCorrupt);
   1.481 +    if (aResult==KErrBadPower)
   1.482 +        return(KErrBadPower);
   1.483 +    if (aResult==KErrDied)  // client thread died
   1.484 +        return(KErrDied);
   1.485 +    if (iMount->Drive().IsChanged())
   1.486 +        {
   1.487 +
   1.488 +        if(! iMount->CheckVolumeTheSame())
   1.489 +            {//-- the media is different now.
   1.490 +            return KErrNotReady;
   1.491 +            }
   1.492 +        else if(!IsRecoverableRemount())
   1.493 +            {
   1.494 +            return KErrAccessDenied;
   1.495 +            }
   1.496 +        }
   1.497 +    return(ERetry);
   1.498 +    }   
   1.499 +
   1.500 +/** @return true if the mount can be remounted for a recoverable error */
   1.501 +TBool TFatDriveInterface::IsRecoverableRemount() const
   1.502 +    {
   1.503 +    if(IsDriveWriteProtected()&&(iMount->Drive().IsWriteableResource()||iMount->Drive().IsCurrentWriteFunction()))
   1.504 +        return(EFalse);
   1.505 +    return(ETrue);
   1.506 +    }
   1.507 +
   1.508 +/** return true if the media is write protected */
   1.509 +TBool TFatDriveInterface::IsDriveWriteProtected() const
   1.510 +    {
   1.511 +    TLocalDriveCapsV2Buf localDriveCaps;
   1.512 +    TInt r=iProxyDrive.Caps(localDriveCaps);
   1.513 +
   1.514 +    if(r!=KErrNone)
   1.515 +        return(EFalse);
   1.516 +
   1.517 +    return((localDriveCaps().iMediaAtt&KMediaAttWriteProtected)!=0);
   1.518 +    }
   1.519 +
   1.520 +
   1.521 +
   1.522 +//---------------------------------------------------------------------------------------------------------------------------------------
   1.523 +
   1.524 +TFatDriveInterface::XProxyDriveWrapper::XProxyDriveWrapper() 
   1.525 +                   :iLocalDrive(0) 
   1.526 +{
   1.527 +    TInt nRes = iLock.CreateLocal();
   1.528 +    ASSERT(nRes == KErrNone);
   1.529 +    (void)nRes; 
   1.530 +}
   1.531 +
   1.532 +
   1.533 +TFatDriveInterface::XProxyDriveWrapper::~XProxyDriveWrapper() 
   1.534 +{
   1.535 +    iLock.Close();
   1.536 +}
   1.537 +
   1.538 +/** 
   1.539 +    Initialise interface wrapper.
   1.540 +    @param  aProxyDrive pointer to the raw drive access interface
   1.541 +    @return true on success
   1.542 +*/
   1.543 +TBool TFatDriveInterface::XProxyDriveWrapper::Init(CProxyDrive* aProxyDrive) 
   1.544 +{
   1.545 +    ASSERT(aProxyDrive);
   1.546 +    if(!iLock.Handle()) //-- the mutex must have been created by constructor
   1.547 +        return EFalse;
   1.548 +    
   1.549 +    iLocalDrive = aProxyDrive;
   1.550 +    return ETrue;
   1.551 +}
   1.552 +
   1.553 +//-- see original TFatDriveInterface methods
   1.554 +
   1.555 +TInt TFatDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   1.556 +{
   1.557 +    EnterCriticalSection();
   1.558 +    TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg, aMessage.Handle(), anOffset);
   1.559 +    LeaveCriticalSection();
   1.560 +    return nRes;
   1.561 +}
   1.562 +       
   1.563 +TInt TFatDriveInterface::XProxyDriveWrapper::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const
   1.564 +{
   1.565 +    EnterCriticalSection();
   1.566 +    TInt nRes = iLocalDrive->Read(aPos, aLength, aTrg);
   1.567 +    LeaveCriticalSection();
   1.568 +    return nRes;
   1.569 +}
   1.570 +
   1.571 +TInt TFatDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
   1.572 +{
   1.573 +    EnterCriticalSection();
   1.574 +    TInt nRes = iLocalDrive->Write(aPos, aLength, aSrc, aMessage.Handle(), anOffset);
   1.575 +    LeaveCriticalSection();
   1.576 +    return nRes;
   1.577 +}
   1.578 +
   1.579 +TInt TFatDriveInterface::XProxyDriveWrapper::Write(TInt64 aPos, const TDesC8& aSrc)
   1.580 +{
   1.581 +    EnterCriticalSection();
   1.582 +    TInt nRes = iLocalDrive->Write(aPos, aSrc);
   1.583 +    LeaveCriticalSection();
   1.584 +    return nRes;
   1.585 +}
   1.586 +
   1.587 +TInt TFatDriveInterface::XProxyDriveWrapper::GetLastErrorInfo(TDes8& aErrorInfo) const
   1.588 +{
   1.589 +    EnterCriticalSection();
   1.590 +    TInt nRes = iLocalDrive->GetLastErrorInfo(aErrorInfo);
   1.591 +    LeaveCriticalSection();
   1.592 +    return nRes;
   1.593 +}
   1.594 +
   1.595 +TInt TFatDriveInterface::XProxyDriveWrapper::Caps(TDes8& anInfo) const
   1.596 +{
   1.597 +    EnterCriticalSection();
   1.598 +    TInt nRes = iLocalDrive->Caps(anInfo);
   1.599 +    LeaveCriticalSection();
   1.600 +    return nRes;
   1.601 +}
   1.602 +
   1.603 +
   1.604 +
   1.605 +
   1.606 +
   1.607 +
   1.608 +
   1.609 +
   1.610 +
   1.611 +
   1.612 +
   1.613 +