userlibandfileserver/fileserver/sfat/sl_disk.cpp
changeset 15 4122176ea935
parent 0 a41df078684a
equal deleted inserted replaced
0:a41df078684a 15:4122176ea935
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // f32\sfat\sl_disk.cpp
    14 // f32\sfat\sl_disk.cpp
    15 // 
    15 // 
    16 //
    16 //
       
    17 
       
    18 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    19 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    20 //!!
       
    21 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
       
    22 //!!
       
    23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       
    24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    17 
    25 
    18 #include "sl_disk.h"
    26 #include "sl_disk.h"
    19 #include "sl_cache.h"
    27 #include "sl_cache.h"
    20 #include "sl_dir_cache.h"
    28 #include "sl_dir_cache.h"
    21 
    29 
    70     ASSERT(iFatMount);
    78     ASSERT(iFatMount);
    71     }
    79     }
    72 
    80 
    73 
    81 
    74 TInt CRawDisk::GetLastErrorInfo(TDes8& /*aErrorInfo*/) const
    82 TInt CRawDisk::GetLastErrorInfo(TDes8& /*aErrorInfo*/) const
    75 	{
    83     {
    76 	return KErrNotSupported;
    84     return KErrNotSupported;
    77 	}
    85     }
    78 
    86 
    79 //################################################################################################################################
    87 //################################################################################################################################
    80 //##    CAtaDisk class implementation
    88 //##    CAtaDisk class implementation
    81 //################################################################################################################################
    89 //################################################################################################################################
    82 
    90 
    83 CAtaDisk::CAtaDisk(CFatMountCB& aFatMount)
    91 CAtaDisk::CAtaDisk(CFatMountCB& aFatMount)
    84          :CRawDisk(aFatMount), iDrive(aFatMount.DriveInterface())
    92          :CRawDisk(aFatMount), iDrive(aFatMount.DriveInterface())
    85 	{
    93     {
    86 	}
    94     }
    87 
    95 
    88 CAtaDisk::~CAtaDisk()
    96 CAtaDisk::~CAtaDisk()
    89     {
    97     {
    90     delete ipDirCache;
    98     delete ipDirCache;
    91     delete iUidCache;
    99     delete iUidCache;
   100     
   108     
   101     @param  aFatMount reference to the owner.
   109     @param  aFatMount reference to the owner.
   102     @return pointer to the constructed object.
   110     @return pointer to the constructed object.
   103 */
   111 */
   104 CAtaDisk* CAtaDisk::NewL(CFatMountCB& aFatMount)
   112 CAtaDisk* CAtaDisk::NewL(CFatMountCB& aFatMount)
   105 	{
   113     {
   106 	__PRINT1(_L("CAtaDisk::NewL() drv:%d"), aFatMount.DriveNumber());
   114     __PRINT1(_L("CAtaDisk::NewL() drv:%d"), aFatMount.DriveNumber());
   107 
   115 
   108     CAtaDisk* pSelf = new (ELeave) CAtaDisk(aFatMount);
   116     CAtaDisk* pSelf = new (ELeave) CAtaDisk(aFatMount);
   109     
   117     
   110     CleanupStack::PushL(pSelf);
   118     CleanupStack::PushL(pSelf);
   111     
   119     
   112     pSelf->ConstructL();
   120     pSelf->ConstructL();
   113     pSelf->InitializeL();
   121     pSelf->InitializeL();
   114     
   122     
   115     CleanupStack::Pop();
   123     CleanupStack::Pop();
   116 
   124 
   117 	return pSelf;
   125     return pSelf;
   118 	}
   126     }
   119 
   127 
   120 //-------------------------------------------------------------------------------------
   128 //-------------------------------------------------------------------------------------
   121 
   129 
   122 /** 2nd stage constructor */
   130 /** 2nd stage constructor */
   123 void CAtaDisk::ConstructL()
   131 void CAtaDisk::ConstructL()
   153 #ifdef USE_DP_DIR_CACHE
   161 #ifdef USE_DP_DIR_CACHE
   154 
   162 
   155     //=========================== create Demand Paging type of the directory cache
   163     //=========================== create Demand Paging type of the directory cache
   156 
   164 
   157     // initialize cache memory manager as all file systems have mounted by now
   165     // initialize cache memory manager as all file systems have mounted by now
   158 	if(CCacheMemoryManagerFactory::CacheMemoryManager())
   166     if(CCacheMemoryManagerFactory::CacheMemoryManager())
   159 		{
   167         {
   160 		// Note: the configuration data of min and max cache size are aligned with the memory size it
   168         // Note: the configuration data of min and max cache size are aligned with the memory size it
   161 		//	occupies in kernel as we are using demand paging subsystem for dynamic cache size support. 
   169         //  occupies in kernel as we are using demand paging subsystem for dynamic cache size support. 
   162 		//  Therefore, they are refered as 'Mem Size' in following calculation.
   170         //  Therefore, they are refered as 'Mem Size' in following calculation.
   163 		//  However, 'Data Size' refers to the logical size of a page, i.e. the actual data size each page
   171         //  However, 'Data Size' refers to the logical size of a page, i.e. the actual data size each page
   164 		//  contains.
   172         //  contains.
   165 		// The constraints we have to consider when setting up the dynamic cache:
   173         // The constraints we have to consider when setting up the dynamic cache:
   166 		// 	1. each page's data size is aligned with cluster size, unless cluster size is bigger than
   174         //  1. each page's data size is aligned with cluster size, unless cluster size is bigger than
   167 		//  	the default maximum page size allowed (typically 32 KB).
   175         //      the default maximum page size allowed (typically 32 KB).
   168 		// 	2. if page's data size is smaller than segment size (typically 4 KB), i.e. the unit size of 
   176         //  2. if page's data size is smaller than segment size (typically 4 KB), i.e. the unit size of 
   169 		//     	demand paging subsystem's page management, we will still use up the whole segment for
   177         //      demand paging subsystem's page management, we will still use up the whole segment for
   170 		// 		that page.
   178         //      that page.
   171 		//  3. the default min and max cache's memory size is pre-defined in  fat_config.cpp file.
   179         //  3. the default min and max cache's memory size is pre-defined in  fat_config.cpp file.
   172 		// 		(see KDef_DynamicDirCacheMin & KDef_DynamicDirCacheMax).
   180         //      (see KDef_DynamicDirCacheMin & KDef_DynamicDirCacheMax).
   173 
   181 
   174 		// calculate page data size (logical view of page size)
   182         // calculate page data size (logical view of page size)
   175 	    const TUint32 DefMaxCachePageLog2 = iFatMount->FatConfig().DynamicDirCacheMaxPageSizeLog2();
   183         const TUint32 DefMaxCachePageLog2 = iFatMount->FatConfig().DynamicDirCacheMaxPageSizeLog2();
   176 	    const TUint32 PageDataSizeLog2 = clustSizeLog2 < DefMaxCachePageLog2 ? clustSizeLog2 : DefMaxCachePageLog2;
   184         const TUint32 PageDataSizeLog2 = clustSizeLog2 < DefMaxCachePageLog2 ? clustSizeLog2 : DefMaxCachePageLog2;
   177 	    
   185         
   178 		// calculate page number, based on memory size we have reserved
   186         // calculate page number, based on memory size we have reserved
   179 	    const TUint32 SegmentSizeLog2 = CCacheMemoryManagerFactory::CacheMemoryManager()->SegmentSizeInBytesLog2();
   187         const TUint32 SegmentSizeLog2 = CCacheMemoryManagerFactory::CacheMemoryManager()->SegmentSizeInBytesLog2();
   180 	    const TUint32 PageMemSizeLog2 = PageDataSizeLog2 < SegmentSizeLog2 ? SegmentSizeLog2 : PageDataSizeLog2;
   188         const TUint32 PageMemSizeLog2 = PageDataSizeLog2 < SegmentSizeLog2 ? SegmentSizeLog2 : PageDataSizeLog2;
   181 	    TUint32 CacheSizeMinInPages = iFatMount->FatConfig().DynamicDirCacheSizeMin() >> PageMemSizeLog2;
   189         TUint32 CacheSizeMinInPages = iFatMount->FatConfig().DynamicDirCacheSizeMin() >> PageMemSizeLog2;
   182 	    TUint32 CacheSizeMaxInPages = iFatMount->FatConfig().DynamicDirCacheSizeMax() >> PageMemSizeLog2;
   190         TUint32 CacheSizeMaxInPages = iFatMount->FatConfig().DynamicDirCacheSizeMax() >> PageMemSizeLog2;
   183 
   191 
   184 	    // cache memory client is connected via name 
   192         // cache memory client is connected via name 
   185 	    TBuf<0x20> clientName = _L("CACHE_MEM_CLIENT:");
   193         TBuf<0x20> clientName = _L("CACHE_MEM_CLIENT:");
   186 		clientName.Append('A'+iFatMount->DriveNumber());
   194         clientName.Append('A'+iFatMount->DriveNumber());
   187 
   195 
   188 		TRAPD(err, ipDirCache = CDynamicDirCache::NewL(iDrive, CacheSizeMinInPages, CacheSizeMaxInPages, PageDataSizeLog2, clientName));
   196         TRAPD(err, ipDirCache = CDynamicDirCache::NewL(iDrive, CacheSizeMinInPages, CacheSizeMaxInPages, PageDataSizeLog2, clientName));
   189 		if (err == KErrNone)
   197         if (err == KErrNone)
   190 	    	{
   198             {
   191 	    	__PRINT4(_L("CDynamicDirCache::NewL(drv:%C, minPageNum:%u, maxPageNum:%u, pageDataSize:%u)\n"), 'A'+iFatMount->DriveNumber(), CacheSizeMinInPages, CacheSizeMaxInPages, 1<<PageDataSizeLog2);
   199             __PRINT4(_L("CDynamicDirCache::NewL(drv:%C, minPageNum:%u, maxPageNum:%u, pageDataSize:%u)\n"), 'A'+iFatMount->DriveNumber(), CacheSizeMinInPages, CacheSizeMaxInPages, 1<<PageDataSizeLog2);
   192 	    	return;
   200             return;
   193 	    	}
   201             }
   194 		}
   202         }
   195 #endif // USE_DP_DIR_CACHE
   203 #endif // USE_DP_DIR_CACHE
   196 
   204 
   197     //=========================== create legacy type of the directory cache
   205     //=========================== create legacy type of the directory cache
   198     ASSERT(!ipDirCache);
   206     ASSERT(!ipDirCache);
   199 
   207 
   248     @param  aDes        data descriptor
   256     @param  aDes        data descriptor
   249 
   257 
   250     @leave on error
   258     @leave on error
   251 */
   259 */
   252 void CAtaDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
   260 void CAtaDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
   253 	{
   261     {
   254     __PRINT3(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aLength);
   262     __PRINT3(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aLength);
   255     iUidCache->ReadL(aPos, aLength, aDes);
   263     iUidCache->ReadL(aPos, aLength, aDes);
   256 	}
   264     }
   257 
   265 
   258 //-------------------------------------------------------------------------------------
   266 //-------------------------------------------------------------------------------------
   259 
   267 
   260 /**
   268 /**
   261     Write data to the media through LRU data cache
   269     Write data to the media through LRU data cache
   264     @param  aDes        data descriptor
   272     @param  aDes        data descriptor
   265 
   273 
   266     @leave on error
   274     @leave on error
   267 */
   275 */
   268 void CAtaDisk::WriteCachedL(TInt64 aPos, const TDesC8& aDes)
   276 void CAtaDisk::WriteCachedL(TInt64 aPos, const TDesC8& aDes)
   269 	{
   277     {
   270     __PRINT3(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aDes.Size());
   278     __PRINT3(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u"), I64HIGH(aPos), I64LOW(aPos), aDes.Size());
   271     iUidCache->WriteL(aPos, aDes);
   279     iUidCache->WriteL(aPos, aDes);
   272 	}
   280     }
   273 
   281 
   274 
   282 
   275 //-------------------------------------------------------------------------------------
   283 //-------------------------------------------------------------------------------------
   276 
   284 
   277 /**
   285 /**
   278     Read data from the media directly without any caches.
   286     Read data from the media directly without any caches.
   279     Mostly used by file IO
   287     Mostly used by file IO
   280 
   288 
   281     @param  aPos        absolute media position
   289     @param  aPos        absolute media position
   282     @param  aLength     how many bytes to read
   290     @param  aLength     how many bytes to read
   283 	@param  aTrg		Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
   291     @param  aTrg        Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
   284 	@param  aMessage	Refrence to server message from request
   292     @param  aMessage    Refrence to server message from request
   285 	@param  anOffset	Offset into read data to write
   293     @param  anOffset    Offset into read data to write
   286 
   294 
   287     @leave on error
   295     @leave on error
   288 */
   296 */
   289 void CAtaDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   297 void CAtaDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const
   290 	{
   298     {
   291 
   299 
   292 	__PRINT4(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
   300     __PRINT4(_L("CAtaDisk::ReadL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
   293 	User::LeaveIfError(iDrive.ReadNonCritical(aPos,aLength,aTrg,aMessage,anOffset));
   301     User::LeaveIfError(iDrive.ReadNonCritical(aPos,aLength,aTrg,aMessage,anOffset));
   294 	}
   302     }
   295 
   303 
   296 //-------------------------------------------------------------------------------------
   304 //-------------------------------------------------------------------------------------
   297 
   305 
   298 /**
   306 /**
   299     Write data to the media directly without any cached.
   307     Write data to the media directly without any cached.
   300     Mostly used by file IO
   308     Mostly used by file IO
   301 
   309 
   302     This method shall invalidate some data caches to keep them in synch with the media.
   310     This method shall invalidate some data caches to keep them in synch with the media.
   303 
   311 
   304     @param aPos		Media position in bytes
   312     @param aPos     Media position in bytes
   305     @param aLength	Length in bytes of write
   313     @param aLength  Length in bytes of write
   306 	@param aTrg		Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
   314     @param aTrg     Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
   307 	@param aMessage	Refrence to server message from request, contains data
   315     @param aMessage Refrence to server message from request, contains data
   308 	@param anOffset	Offset into write data to use in write
   316     @param anOffset Offset into write data to use in write
   309 
   317 
   310     @leave on error
   318     @leave on error
   311 */
   319 */
   312 void CAtaDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
   320 void CAtaDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset)
   313 	{
   321     {
   314     __PRINT4(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
   322     __PRINT4(_L("CAtaDisk::WriteL() pos:%u:%u, len:%u, offset:%u"), I64HIGH(aPos), I64LOW(aPos), aLength, anOffset);
   315 
   323 
   316 	//-- write data to the media directly
   324     //-- write data to the media directly
   317     User::LeaveIfError(iDrive.WriteNonCritical(aPos,aLength,aSrc,aMessage,anOffset));
   325     User::LeaveIfError(iDrive.WriteNonCritical(aPos,aLength,aSrc,aMessage,anOffset));
   318 
   326 
   319     //-- we need to invalidate UID cache page that corresponds to aPos (if any). This is UID caching specific. UID is stored in the first few bytes of 
   327     //-- we need to invalidate UID cache page that corresponds to aPos (if any). This is UID caching specific. UID is stored in the first few bytes of 
   320     //-- the executable module and therefore belongs to one cache page only.
   328     //-- the executable module and therefore belongs to one cache page only.
   321     //-- If someone writes to the beginning of the exe module file, corresponding UID cache page will be invalidated and re-read from the media later
   329     //-- If someone writes to the beginning of the exe module file, corresponding UID cache page will be invalidated and re-read from the media later
   322     iUidCache->InvalidateCachePage(aPos); 
   330     iUidCache->InvalidateCachePage(aPos); 
   323 
   331 
   324     //-- invalidate affected(if any) part of the FAT cache in the case if someone used to write data to FAT area, which usually do not happen 
   332     //-- invalidate affected(if any) part of the FAT cache in the case if someone used to write data to FAT area, which usually do not happen 
   325     iFatMount->FAT().InvalidateCacheL(aPos,aLength);
   333     iFatMount->FAT().InvalidateCacheL(aPos,aLength);
   326 
   334 
   327 	}
   335     }
   328 
   336 
   329 //-------------------------------------------------------------------------------------
   337 //-------------------------------------------------------------------------------------
   330 
   338 
   331 /** Get information for last disk error */
   339 /** Get information for last disk error */
   332 TInt CAtaDisk::GetLastErrorInfo(TDes8& aErrorInfo) const
   340 TInt CAtaDisk::GetLastErrorInfo(TDes8& aErrorInfo) const
   333 	{
   341     {
   334 	return iDrive.GetLastErrorInfo(aErrorInfo);
   342     return iDrive.GetLastErrorInfo(aErrorInfo);
   335 	}
   343     }
   336 
   344 
   337 
   345 
   338 //-------------------------------------------------------------------------------------
   346 //-------------------------------------------------------------------------------------
   339 /** Invalidate whole UID cache */
   347 /** Invalidate whole UID cache */
   340 void CAtaDisk::InvalidateUidCache()
   348 void CAtaDisk::InvalidateUidCache()
   365     
   373     
   366     @param  aFatMount reference to the owner.
   374     @param  aFatMount reference to the owner.
   367     @return pointer to the constructed object.
   375     @return pointer to the constructed object.
   368 */
   376 */
   369 CRamDisk* CRamDisk::NewL(CFatMountCB& aFatMount)
   377 CRamDisk* CRamDisk::NewL(CFatMountCB& aFatMount)
   370 	{
   378     {
   371     __PRINT1(_L("CRamDisk::NewL() drv:%d"), aFatMount.DriveNumber());
   379     __PRINT1(_L("CRamDisk::NewL() drv:%d"), aFatMount.DriveNumber());
   372 	CRamDisk* pSelf = new(ELeave)CRamDisk(aFatMount);
   380     CRamDisk* pSelf = new(ELeave)CRamDisk(aFatMount);
   373 
   381 
   374     CleanupStack::PushL(pSelf);
   382     CleanupStack::PushL(pSelf);
   375   
   383   
   376     pSelf->InitializeL();
   384     pSelf->InitializeL();
   377     
   385     
   378     CleanupStack::Pop();
   386     CleanupStack::Pop();
   379 
   387 
   380 	return pSelf;
   388     return pSelf;
   381 	}
   389     }
   382 
   390 
   383 CRamDisk::CRamDisk(CFatMountCB& aFatMount)
   391 CRamDisk::CRamDisk(CFatMountCB& aFatMount)
   384 	     :CRawDisk(aFatMount)
   392          :CRawDisk(aFatMount)
   385     {
   393     {
   386 	}
   394     }
   387 
   395 
   388 //-------------------------------------------------------------------------------------
   396 //-------------------------------------------------------------------------------------
   389 
   397 
   390 /**
   398 /**
   391     Initialises and re-initialises the object.
   399     Initialises and re-initialises the object.
   408 
   416 
   409 
   417 
   410 
   418 
   411 /** @return the start address of the Ram Drive in low memory */
   419 /** @return the start address of the Ram Drive in low memory */
   412 TUint8* CRamDisk::RamDiskBase() const
   420 TUint8* CRamDisk::RamDiskBase() const
   413 	{
   421     {
   414 	return iRamDiskBase;
   422     return iRamDiskBase;
   415 	}
   423     }
   416 
   424 
   417 //-------------------------------------------------------------------------------------
   425 //-------------------------------------------------------------------------------------
   418 //
   426 //
   419 // Read aLength of data from the disk
   427 // Read aLength of data from the disk
   420 //
   428 //
   421 void CRamDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
   429 void CRamDisk::ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const
   422 	{
   430     {
   423 	
   431     
   424 	__PRINT3(_L("CRamDisk::ReadL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),I64LOW(aPos),aLength);
   432     __PRINT3(_L("CRamDisk::ReadL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),I64LOW(aPos),aLength);
   425 	__ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
   433     __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
   426 	Mem::Copy((TUint8*)aDes.Ptr(),RamDiskBase()+I64LOW(aPos),aLength);
   434     Mem::Copy((TUint8*)aDes.Ptr(),RamDiskBase()+I64LOW(aPos),aLength);
   427 	aDes.SetLength(aLength);
   435     aDes.SetLength(aLength);
   428 	}
   436     }
   429 
   437 
   430 //-------------------------------------------------------------------------------------
   438 //-------------------------------------------------------------------------------------
   431 //
   439 //
   432 // Write aLength of data to the disk
   440 // Write aLength of data to the disk
   433 //
   441 //
   434 void CRamDisk::WriteCachedL(TInt64 aPos,const TDesC8& aDes)
   442 void CRamDisk::WriteCachedL(TInt64 aPos,const TDesC8& aDes)
   435 	{
   443     {
   436 
   444 
   437 	__PRINT3(_L("CRamDisk::WriteL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),aPos,aDes.Length());
   445     __PRINT3(_L("CRamDisk::WriteL Base 0x%x Pos 0x%x, Len %d"),RamDiskBase(),aPos,aDes.Length());
   438 	__ASSERT_ALWAYS(aPos+aDes.Length()<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
   446     __ASSERT_ALWAYS(aPos+aDes.Length()<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
   439 	Mem::Copy(RamDiskBase()+I64LOW(aPos),(TUint8*)aDes.Ptr(),aDes.Length());
   447     Mem::Copy(RamDiskBase()+I64LOW(aPos),(TUint8*)aDes.Ptr(),aDes.Length());
   440 	}
   448     }
   441 	
   449     
   442 
   450 
   443 //-------------------------------------------------------------------------------------
   451 //-------------------------------------------------------------------------------------
   444 //
   452 //
   445 // Read from ramDrive into thread relative descriptor
   453 // Read from ramDrive into thread relative descriptor
   446 //
   454 //
   447 void CRamDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* /*aTrg*/,const RMessagePtr2 &aMessage,TInt anOffset) const
   455 void CRamDisk::ReadL(TInt64 aPos,TInt aLength,const TAny* /*aTrg*/,const RMessagePtr2 &aMessage,TInt anOffset) const
   448 	{
   456     {
   449 	__PRINT2(_L("CRamDisk::ReadL TAny* Pos 0x%x, Len %d"),aPos,aLength);
   457     __PRINT2(_L("CRamDisk::ReadL TAny* Pos 0x%x, Len %d"),aPos,aLength);
   450 	__ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
   458     __ASSERT_ALWAYS((aPos+aLength<=I64INT(iFatMount->Size())) && (aLength>=0),User::Leave(KErrCorrupt));
   451 	TUint8* pos=RamDiskBase()+I64LOW(aPos);
   459     TUint8* pos=RamDiskBase()+I64LOW(aPos);
   452 	TPtrC8 buf(pos,aLength);
   460     TPtrC8 buf(pos,aLength);
   453 	aMessage.WriteL(0,buf,anOffset);
   461     aMessage.WriteL(0,buf,anOffset);
   454 	}
   462     }
   455 
   463 
   456 //-------------------------------------------------------------------------------------
   464 //-------------------------------------------------------------------------------------
   457 //
   465 //
   458 // Write from thread relative descriptor into ramDrive
   466 // Write from thread relative descriptor into ramDrive
   459 //
   467 //
   460 void CRamDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* /*aSrc*/,const RMessagePtr2 &aMessage,TInt anOffset)
   468 void CRamDisk::WriteL(TInt64 aPos,TInt aLength,const TAny* /*aSrc*/,const RMessagePtr2 &aMessage,TInt anOffset)
   461 	{
   469     {
   462 	__PRINT2(_L("CRamDisk::WriteL TAny* Pos 0x%x, Len %d"),aPos,aLength);
   470     __PRINT2(_L("CRamDisk::WriteL TAny* Pos 0x%x, Len %d"),aPos,aLength);
   463 	__ASSERT_ALWAYS(aPos+aLength<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
   471     __ASSERT_ALWAYS(aPos+aLength<=I64INT(iFatMount->Size()),User::Leave(KErrCorrupt));
   464 	TUint8* pos=RamDiskBase()+I64LOW(aPos);
   472     TUint8* pos=RamDiskBase()+I64LOW(aPos);
   465 	TPtr8 buf(pos,aLength);
   473     TPtr8 buf(pos,aLength);
   466 	aMessage.ReadL(0,buf,anOffset);
   474     aMessage.ReadL(0,buf,anOffset);
   467 	}
   475     }
   468 
   476 
   469 
   477 
   470 
   478 
   471 
   479 
   472 
   480 
   473 
   481 
   474 
   482 
   475 
   483 
   476 
   484 
   477 
   485 
   478 
   486 
   479 
   487 
   480 
   488 
   481 
   489 
   482 
   490 
   483 
   491 
   484 
   492 
   485 
   493 
   486 
   494 
   487 
   495 
   488 
   496 
   489 
   497 
   490 
   498 
   491 
   499 
   492 
   500 
   493 
   501 
   494 
   502