userlibandfileserver/fileserver/sfile/sf_debug.cpp
changeset 201 43365a9b78a3
parent 109 b3a1d9898418
child 247 d8d70de2bd36
--- a/userlibandfileserver/fileserver/sfile/sf_debug.cpp	Wed Jun 23 19:44:53 2010 +0300
+++ b/userlibandfileserver/fileserver/sfile/sf_debug.cpp	Tue Jul 06 15:50:07 2010 +0300
@@ -19,8 +19,9 @@
 #include <f32dbg.h>
 #include "f32image.h"
 #include <F32plugin.h>
+#include <filesystem_fat.h>
 #include "sf_file_cache.h"
-
+#include "sf_memory_man.h"
 
 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
 
@@ -28,6 +29,29 @@
 // ONLY INCLUDED IN DEBUG BUILDS
 //
 
+void PrintOpenFiles()
+	{
+	CCacheManager* manager = CCacheManagerFactory::CacheManager();
+	TInt allocatedSegmentCount = manager ? manager->Stats().iAllocatedSegmentCount : 0;
+	TInt lockedSegmentCount = manager ? manager->Stats().iLockedSegmentCount : 0;
+	TInt fileCount = manager ? manager->Stats().iFileCount : 0;
+	TInt filesOnClosedQueue = manager ? manager->Stats().iFilesOnClosedQueue : 0;
+
+	RDebug::Print(_L("TRACE: Open files %d allocatedSegmentCount %d lockedSegmentCount %d fileCount %d filesOnClosedQueue %d\n"), 
+		Files->Count(), allocatedSegmentCount, lockedSegmentCount, fileCount, filesOnClosedQueue);
+
+	Files->Lock();
+	TInt count=Files->Count();
+
+	for (TInt n=0; n<count; n++)
+		{
+		CFileCB* file=(CFileCB*)(*Files)[n];
+
+		RDebug::Print(_L("%3d: %C:%S fc %x sz %lx\n"), n, file->Drive().DriveNumber() + 'A', &file->FileNameF(), file->FileCache(), file->CachedSize64());
+		}
+	Files->Unlock();
+	}
+
 void PrintHeapSize(const TDesC& aMessage)
 //
 // Display the total memory available
@@ -625,6 +649,101 @@
         	
         	return KErrNone;
         	}
+        case KControlIoGlobalCacheConfig:
+		// read ESTART.TXT file for global memory settings
+            {
+            TGlobalCacheConfig globalCacheConfig;
+            TInt32 rel;
+            
+            const TInt KByteToByteShift = 10;
+            _LIT8(KLitSectionNameCacheMemory,"CacheMemory");
+            
+            if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("GlobalCacheMemorySize"), rel))
+                globalCacheConfig.iGlobalCacheSizeInBytes = rel << KByteToByteShift;
+            else
+                globalCacheConfig.iGlobalCacheSizeInBytes = KErrNotFound;
+
+            if (F32Properties::GetInt(KLitSectionNameCacheMemory, _L8("LowMemoryThreshold"), rel))
+                globalCacheConfig.iGlobalLowMemoryThreshold = rel;
+            else
+                globalCacheConfig.iGlobalLowMemoryThreshold = KErrNotFound;
+
+            TPckgBuf<TGlobalCacheConfig> pkgBuf(globalCacheConfig);
+            TInt r=aRequest->Write(2,pkgBuf);
+            return r;
+            }
+        case KControlIoGlobalCacheInfo:
+    	// get system's current global cache memory info
+            {
+            TGlobalCacheInfo info;
+            info.iGlobalCacheSizeInBytes = TGlobalCacheMemorySettings::CacheSize();
+            info.iGlobalLowMemoryThreshold = TGlobalCacheMemorySettings::LowMemoryThreshold();
+            TPckgBuf<TGlobalCacheInfo> pkgBuf(info);
+            TInt r=aRequest->Write(2,pkgBuf);
+            return r;
+            }
+         case KControlIoDirCacheConfig:
+         // read ESTART.TXT file for per-drive directory cache settings
+            {
+            TInt driveNumber = aRequest->Drive()->DriveNumber();
+            TDirCacheConfig dirCacheConfig;
+            TInt32 rel;
+            dirCacheConfig.iDrive = driveNumber;
+            TBuf8<32> driveSection;
+            driveSection.Format(_L8("Drive%c"), 'A' + driveNumber);
+            
+            if (F32Properties::GetInt(driveSection, _L8("FAT_LeafDirCacheSize"), rel))
+                dirCacheConfig.iLeafDirCacheSize = rel;
+            else
+                dirCacheConfig.iLeafDirCacheSize = KErrNotFound;
+
+            if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMin"), rel))
+                dirCacheConfig.iDirCacheSizeMin = rel << KByteToByteShift;
+            else
+                dirCacheConfig.iDirCacheSizeMin = KErrNotFound;
+
+            if (F32Properties::GetInt(driveSection, _L8("FAT_DirCacheSizeMax"), rel))
+                dirCacheConfig.iDirCacheSizeMax = rel << KByteToByteShift;
+            else
+                dirCacheConfig.iDirCacheSizeMax = KErrNotFound;
+
+            TPckgBuf<TDirCacheConfig> pkgBuf(dirCacheConfig);
+            TInt r=aRequest->Write(2,pkgBuf);
+            return r;
+            }
+         case KControlIoDirCacheInfo:
+         // get system's current per-drive directory cache settings
+		 //  currently only supports FAT file system
+             {
+             TFSName fsName;
+             aRequest->Drive()->CurrentMount().FileSystemName(fsName);
+             if (fsName.CompareF(KFileSystemName_FAT) == 0)
+                 {
+                 // 16 is the control cmd used for FAT
+                 //  see EFATDirCacheInfo in FAT code please. 
+                 const TInt KFATDirCacheInfo = 16;
+                 return(aRequest->Drive()->ControlIO(aRequest->Message(),KFATDirCacheInfo,param1,param2));
+                 }
+             return KErrNotSupported;
+             }
+         case KControlIoSimulateMemoryLow:
+             {
+             CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager();
+             if (cacheMemManager)
+                 cacheMemManager->SetMemoryLow(ETrue);
+             else
+                 return KErrNotSupported;
+             return KErrNone;
+             }
+         case KControlIoStopSimulateMemoryLow:
+             {
+             CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager();
+             if (cacheMemManager)
+                 cacheMemManager->SetMemoryLow(EFalse);
+             else
+                 return KErrNotSupported;
+             return KErrNone;
+             }
 		
 		}
 #endif