| author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> | 
| Thu, 15 Jul 2010 20:11:42 +0300 | |
| branch | RCL_3 | 
| changeset 41 | 0ffb4e86fcc9 | 
| parent 21 | e7d2d738d3c2 | 
| child 42 | a179b74831c9 | 
| permissions | -rw-r--r-- | 
| 0 | 1 | // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). | 
| 2 | // All rights reserved. | |
| 3 | // This component and the accompanying materials are made available | |
| 4 | // under the terms of the License "Eclipse Public License v1.0" | |
| 5 | // which accompanies this distribution, and is available | |
| 6 | // at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
| 7 | // | |
| 8 | // Initial Contributors: | |
| 9 | // Nokia Corporation - initial contribution. | |
| 10 | // | |
| 11 | // Contributors: | |
| 12 | // | |
| 13 | // Description: | |
| 14 | // f32\sfile\sf_debug.cpp | |
| 15 | // | |
| 16 | // | |
| 17 | ||
| 18 | #include "sf_std.h" | |
| 19 | #include <f32dbg.h> | |
| 20 | #include "f32image.h" | |
| 21 | #include <F32plugin.h> | |
| 22 | #include "sf_file_cache.h" | |
| 23 | ||
| 24 | ||
| 25 | #if defined(_DEBUG) || defined(_DEBUG_RELEASE) | |
| 26 | ||
| 27 | // | |
| 28 | // ONLY INCLUDED IN DEBUG BUILDS | |
| 29 | // | |
| 30 | ||
| 41 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 31 | void PrintOpenFiles() | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 32 | 	{
 | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 33 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 34 | TInt allocatedSegmentCount = manager ? manager->Stats().iAllocatedSegmentCount : 0; | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 35 | TInt lockedSegmentCount = manager ? manager->Stats().iLockedSegmentCount : 0; | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 36 | TInt fileCount = manager ? manager->Stats().iFileCount : 0; | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 37 | TInt filesOnClosedQueue = manager ? manager->Stats().iFilesOnClosedQueue : 0; | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 38 | |
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 39 | 	RDebug::Print(_L("TRACE: Open files %d allocatedSegmentCount %d lockedSegmentCount %d fileCount %d filesOnClosedQueue %d\n"), 
 | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 40 | Files->Count(), allocatedSegmentCount, lockedSegmentCount, fileCount, filesOnClosedQueue); | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 41 | |
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 42 | Files->Lock(); | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 43 | TInt count=Files->Count(); | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 44 | |
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 45 | for (TInt n=0; n<count; n++) | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 46 | 		{
 | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 47 | CFileCB* file=(CFileCB*)(*Files)[n]; | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 48 | |
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 49 | 		RDebug::Print(_L("%3d: %C:%S fc %x sz %lx\n"), n, file->Drive().DriveNumber() + 'A', &file->FileNameF(), file->FileCache(), file->CachedSize64());
 | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 50 | } | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 51 | Files->Unlock(); | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 52 | } | 
| 
0ffb4e86fcc9
Revision: 201027
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
21diff
changeset | 53 | |
| 0 | 54 | void PrintHeapSize(const TDesC& aMessage) | 
| 55 | // | |
| 56 | // Display the total memory available | |
| 57 | // | |
| 58 | 	{
 | |
| 59 | ||
| 60 | TInt biggest; | |
| 61 | TInt heapSize = User::Allocator().Available(biggest); | |
| 62 | 	RDebug::Print(_L("%S size=0x%x largest cell=0x%x"),&aMessage,heapSize,biggest);
 | |
| 63 | } | |
| 64 | ||
| 65 | static void SetAllocFailure(const RMessage2* aMessage) | |
| 66 | // | |
| 67 | // Set alloc failure after allocCount allocations | |
| 68 | // | |
| 69 | 	{
 | |
| 70 | ||
| 71 | UserHeapAllocFailCount=aMessage->Int1(); | |
| 72 | KernHeapAllocFailCount=UserHeapAllocFailCount; | |
| 73 | if (UserHeapAllocFailCount>=0) | |
| 74 | 		{
 | |
| 75 | __UHEAP_FAILNEXT(UserHeapAllocFailCount); | |
| 76 | __KHEAP_FAILNEXT(KernHeapAllocFailCount); | |
| 77 | } | |
| 78 | else | |
| 79 | 		{
 | |
| 80 | __UHEAP_RESET; | |
| 81 | __KHEAP_RESET; | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | TInt FsDebugFunction(CFsRequest* aRequest) | |
| 86 | // | |
| 87 | // SetAllocFailure - Set alloc failure after allocCount allocations | |
| 88 | // SetErrorCondition - Set simulated error failure | |
| 89 | // SetDebugRegister - Trigger tracing output | |
| 90 | // DebugNotify - Request notification of a file server event - .FSY specific | |
| 91 | // | |
| 92 | 	{
 | |
| 93 | ||
| 94 | TInt r=KErrNone; | |
| 95 | const RMessage2* message=&(aRequest->Message()); | |
| 96 | switch (message->Int0()) | |
| 97 | 		{
 | |
| 98 | case EFsSetAllocFailure: | |
| 99 | SetAllocFailure(message); | |
| 100 | break; | |
| 101 | case EFsSetErrorCondition: | |
| 102 | ErrorCondition=message->Int1(); | |
| 103 | ErrorCount=message->Int2(); | |
| 104 | break; | |
| 105 | case EFsSetDebugRegister: | |
| 106 | DebugReg=message->Int1(); | |
| 107 | break; | |
| 108 | case EFsDebugNotify: | |
| 109 | 		{
 | |
| 110 | TUint notifyType=(aRequest->Message().Int2())&KDebugNotifyMask; | |
| 111 | if (notifyType) | |
| 112 | 			{
 | |
| 113 | CDebugChangeInfo* info=new CDebugChangeInfo; | |
| 114 | if(!info) | |
| 115 | return(KErrNoMemory); | |
| 116 | const RMessage2& m=aRequest->Message(); | |
| 117 | info->Initialise(notifyType,(TRequestStatus*)m.Ptr3(),m,aRequest->Session()); | |
| 118 | r=FsNotify::AddDebug(info); | |
| 119 | if(r!=KErrNone) | |
| 120 | delete(info); | |
| 121 | else | |
| 122 | aRequest->SetCompleted(EFalse); | |
| 123 | } | |
| 124 | else | |
| 125 | r=KErrArgument; | |
| 126 | break; | |
| 127 | } | |
| 128 | default: | |
| 129 | break; | |
| 130 | }; | |
| 131 | return(r); | |
| 132 | } | |
| 133 | ||
| 134 | TBool SimulateError(const RMessage2* aMessage) | |
| 135 | // | |
| 136 | // Return an error message if ErrorCount<=0 | |
| 137 | // | |
| 138 | 	{
 | |
| 139 | TInt function = aMessage->Function() & KIpcFunctionMask; | |
| 140 | ||
| 141 | if (ErrorCondition!=KErrNone && | |
| 142 | ( | |
| 143 | function!=EFsDebugFunction || aMessage->Int0()!=EFsSetErrorCondition) && | |
| 144 | function!=EFsNotifyChangeCancel && | |
| 145 | function!=EFsNotifyChangeCancelEx && | |
| 146 | function!=EFsNotifyDiskSpaceCancel && | |
| 147 | function!=EFsFormatSubClose && | |
| 148 | function!=EFsDirSubClose && | |
| 149 | function!=EFsFileSubClose && | |
| 150 | function!=EFsRawSubClose && | |
| 151 | function!=EFsUnclamp && | |
| 152 | ||
| 153 | //-- this operation must not fail. It can only fail if the client's thread has died. | |
| 154 | //-- in this case whole session will be cleaned up. | |
| 155 | function!=EFsFileAdopt | |
| 156 | ) | |
| 157 | 		{
 | |
| 158 | if (ErrorCount<=0) | |
| 159 | return(ETrue); | |
| 160 | ErrorCount--; | |
| 161 | } | |
| 162 | return(EFalse); | |
| 163 | } | |
| 164 | ||
| 165 | ||
| 166 | TPtrC GetFunctionName(TInt aFunction) | |
| 167 | // | |
| 168 | // Print number of alloc fails to complete a given function | |
| 169 | // | |
| 170 | 	{
 | |
| 171 | ||
| 172 | switch (aFunction) | |
| 173 | 		{
 | |
| 174 | 	case EFsDebugFunction: return _L("EFsDebugFunction");
 | |
| 175 | 	case EFsAddFileSystem: return _L("EFsAddFileSystem");
 | |
| 176 | 	case EFsRemoveFileSystem: return _L("EFsRemoveFileSystem");
 | |
| 177 | 	case EFsMountFileSystem: return _L("EFsMountFileSystem");
 | |
| 178 | 	case EFsNotifyChange: return _L("EFsNotifyChange");
 | |
| 179 | 	case EFsNotifyChangeCancel: return _L("EFsNotifyChangeCancel");
 | |
| 180 | 	case EFsDriveList: return _L("EFsDriveList");
 | |
| 181 | 	case EFsDrive: return _L("EFsDrive");
 | |
| 182 | 	case EFsVolume: return _L("EFsVolume");
 | |
| 183 | 	case EFsSetVolume: return _L("EFsSetVolume");
 | |
| 184 | 	case EFsSubst: return _L("EFsSubst");
 | |
| 185 | 	case EFsSetSubst: return _L("EFsSetSubst");
 | |
| 186 | 	case EFsRealName: return _L("EFsRealName");
 | |
| 187 | 	case EFsDefaultPath: return _L("EFsDefaultPath");
 | |
| 188 | 	case EFsSetDefaultPath: return _L("EFsSetDefaultPath");
 | |
| 189 | 	case EFsSessionPath: return _L("EFsSessionPath");
 | |
| 190 | 	case EFsSetSessionPath: return _L("EFsSetSessionPath");
 | |
| 191 | 	case EFsMkDir: return _L("EFsMkDir");
 | |
| 192 | 	case EFsRmDir: return _L("EFsRmDir");
 | |
| 193 | 	case EFsParse: return _L("EFsParse");
 | |
| 194 | 	case EFsDelete: return _L("EFsDelete");
 | |
| 195 | 	case EFsRename: return _L("EFsRename");
 | |
| 196 | 	case EFsReplace: return _L("EFsReplace");
 | |
| 197 | 	case EFsEntry: return _L("EFsEntry");
 | |
| 198 | 	case EFsSetEntry: return _L("EFsSetEntry");
 | |
| 199 | 	case EFsGetDriveName: return _L("EFsGetDriveName");
 | |
| 200 | 	case EFsSetDriveName: return _L("EFsSetDriveName");
 | |
| 201 | 	case EFsFormatSubClose: return _L("EFsFormatSubClose");
 | |
| 202 | 	case EFsDirSubClose: return _L("EFsDirSubClose");
 | |
| 203 | 	case EFsFileSubClose: return _L("EFsFileSubClose");
 | |
| 204 | 	case EFsRawSubClose: return _L("EFsRawSubClose");
 | |
| 205 | 	case EFsFileOpen: return _L("EFsFileOpen");
 | |
| 206 | 	case EFsFileCreate: return _L("EFsFileCreate");
 | |
| 207 | 	case EFsFileReplace: return _L("EFsFileReplace");
 | |
| 208 | 	case EFsFileTemp: return _L("EFsFileTemp");
 | |
| 209 | 	case EFsFileRead: return _L("EFsFileRead");
 | |
| 210 | 	case EFsFileWrite: return _L("EFsFileWrite");
 | |
| 211 | 	case EFsFileLock: return _L("EFsFileLock");
 | |
| 212 | 	case EFsFileUnLock: return _L("EFsFileUnLock");
 | |
| 213 | 	case EFsFileSeek: return _L("EFsFileSeek");
 | |
| 214 | 	case EFsFileFlush: return _L("EFsFileFlush");
 | |
| 215 | 	case EFsFileSize: return _L("EFsFileSize");
 | |
| 216 | 	case EFsFileSetSize: return _L("EFsFileSetSize");
 | |
| 217 | 	case EFsFileAtt: return _L("EFsFileAtt");
 | |
| 218 | 	case EFsFileSetAtt: return _L("EFsFileSetAtt");
 | |
| 219 | 	case EFsFileModified: return _L("EFsFileModified");
 | |
| 220 | 	case EFsFileSetModified: return _L("EFsFileSetModified");
 | |
| 221 | 	case EFsFileSet: return _L("EFsFileSet");
 | |
| 222 | 	case EFsFileChangeMode: return _L("EFsFileChangeMode");
 | |
| 223 | 	case EFsFileRename: return _L("EFsFileRename");
 | |
| 224 | 	case EFsDirOpen: return _L("EFsDirOpen");
 | |
| 225 | 	case EFsDirReadOne: return _L("EFsDirReadOne");
 | |
| 226 | 	case EFsDirReadPacked: return _L("EFsDirReadPacked");
 | |
| 227 | 	case EFsFormatOpen: return _L("EFsFormatOpen");
 | |
| 228 | 	case EFsFormatNext: return _L("EFsFormatNext");
 | |
| 229 | 	case EFsRawDiskOpen: return _L("EFsRawDiskOpen");
 | |
| 230 | 	case EFsRawDiskRead: return _L("EFsRawDiskRead");
 | |
| 231 | 	case EFsRawDiskWrite: return _L("EFsRawDiskWrite");
 | |
| 232 | 	case EFsResourceCountMarkStart: return _L("EFsResourceCountMarkStart");
 | |
| 233 | 	case EFsResourceCountMarkEnd: return _L("EFsResourceCountMarkEnd");
 | |
| 234 | 	case EFsResourceCount: return _L("EFsResourceCount");
 | |
| 235 | 	case EFsCheckDisk: return _L("EFsCheckDisk");
 | |
| 236 | 	case EFsGetShortName: return _L("EFsGetShortName");
 | |
| 237 | 	case EFsGetLongName: return _L("EFsGetLongName");
 | |
| 238 | 	case EFsIsFileOpen: return _L("EFsIsFileOpen");
 | |
| 239 | 	case EFsListOpenFiles: return _L("EFsListOpenFiles");
 | |
| 240 | 	case EFsSetNotifyUser: return _L("EFsSetNotifyUser");
 | |
| 241 | 	case EFsIsFileInRom: return _L("EFsIsFileInRom");
 | |
| 242 | 	case EFsGetNotifyUser: return _L("EFsGetNotifyUser");
 | |
| 243 | 	case EFsIsValidName: return _L("EFsIsValidName");
 | |
| 244 | 	case EFsReadFileSection: return _L("EFsReadFileSection");
 | |
| 245 | 	case EFsNotifyChangeEx: return _L("EFsNotifyChangeEx");
 | |
| 246 | 	case EFsNotifyChangeCancelEx: return _L("EFsNotifyChangeCancelEx");
 | |
| 247 | 	case EFsDismountFileSystem: return _L("EFsDismountFileSystem");
 | |
| 248 | 	case EFsFileSystemName: return _L("EFsFileSystemName");
 | |
| 249 | 	case EFsScanDrive: return _L("EFsScanDrive");
 | |
| 250 | 	case EFsControlIo: return _L("EFsControlIo");
 | |
| 251 | 	case EFsLockDrive: return _L("EFsLockDrive");
 | |
| 252 | 	case EFsUnlockDrive: return _L("EFsUnlockDrive");
 | |
| 253 | 	case EFsClearPassword: return _L("EFsClearPassword");
 | |
| 254 | 	case EFsNotifyDiskSpace: return _L("EFsNotifyDiskSpace");
 | |
| 255 | 	case EFsNotifyDiskSpaceCancel: return _L("EFsNotifyDiskSpaceCancel");
 | |
| 256 | 	case EFsMountFileSystemScan: return _L("EFsMountFileSystemScan");
 | |
| 257 | 	case EFsSessionToPrivate: return _L("EFsSessionToPrivate");
 | |
| 258 | 	case EFsPrivatePath: return _L("EFsPrivatePath");
 | |
| 259 | 	case EFsCreatePrivatePath: return _L("EFsCreatePrivatePath");
 | |
| 260 | 	case EFsFileDrive: return _L("EFsFileDrive");
 | |
| 261 | 	case EFsRemountDrive: return _L("EFsRemountDrive");
 | |
| 262 | 	case EFsAddExtension: return _L("EFsAddExtension");
 | |
| 263 | 	case EFsMountExtension: return _L("EFsMountExtension");
 | |
| 264 | 	case EFsDismountExtension: return _L("EFsDismountExtension");
 | |
| 265 | 	case EFsRemoveExtension: return _L("EFsRemoveExtension");
 | |
| 266 | 	case EFsExtensionName: return _L("EFsExtensionName");
 | |
| 267 | 	case EFsStartupInitComplete: return _L("EFsStartupInitComplete");
 | |
| 268 | 	case EFsSetLocalDriveMapping: return _L("EFsSetLocalDriveMapping");
 | |
| 269 | 	case EFsFileDuplicate: return _L("EFsFileDuplicate");
 | |
| 270 | 	case EFsFileAdopt: return _L("EFsFileAdopt");
 | |
| 271 | 	case EFsFinaliseDrive: return _L("EFsFinaliseDrive");
 | |
| 272 | 	case EFsSwapFileSystem: return _L("EFsSwapFileSystem");
 | |
| 273 | 	case EFsErasePassword: return _L("EFsErasePassword");
 | |
| 274 | 	case EFsReserveDriveSpace: return _L("EFsReserveDriveSpace");
 | |
| 275 | 	case EFsGetReserveAccess: return _L("EFsGetReserveAccess");
 | |
| 276 | 	case EFsReleaseReserveAccess: return _L("EFsReleaseReserveAccess");
 | |
| 277 | 	case EFsFileName: return _L("EFsFileName");
 | |
| 278 |     case EFsGetMediaSerialNumber: return _L("EFsGetMediaSerialNumber");
 | |
| 279 | 	case EFsFileFullName: return _L("EFsFileFullName");
 | |
| 280 | 	case EFsAddPlugin: return _L("EFsAddPlugin");
 | |
| 281 | 	case EFsRemovePlugin: return _L("EFsRemovePlugin");
 | |
| 282 | 	case EFsMountPlugin: return _L("EFsMountPlugin");
 | |
| 283 | 	case EFsDismountPlugin: return _L("EFsDismountPlugin");
 | |
| 284 | 	case EFsPluginName: return _L("EFsPluginName");
 | |
| 285 | 	case EFsPluginOpen: return _L("EFsPluginOpen");
 | |
| 286 | 	case EFsPluginSubClose: return _L("EFsPluginSubClose");
 | |
| 287 | 	case EFsPluginDoRequest: return _L("EFsPluginDoRequest");
 | |
| 288 | 	case EFsPluginDoControl: return _L("EFsPluginDoControl");
 | |
| 289 | 	case EFsPluginDoCancel: return _L("EFsPluginDoCancel");
 | |
| 290 | 	case EFsNotifyDismount: return _L("EFsNotifyDismount");
 | |
| 291 | 	case EFsNotifyDismountCancel: return _L("EFsNotifyDismountCancel");
 | |
| 292 | 	case EFsAllowDismount: return _L("EFsAllowDismount");
 | |
| 293 | 	case EFsSetStartupConfiguration: return _L("EFsSetStartupConfiguration");
 | |
| 294 | 	case EFsFileReadCancel: return _L("EFsFileReadCancel");
 | |
| 295 | 	case EFsAddCompositeMount: return _L("EFsAddCompositeMount");
 | |
| 296 | 	case EFsSetSessionFlags: return _L("EFsSetSessionFlags");
 | |
| 297 | 	case EFsSetSystemDrive: return _L("EFsSetSystemDrive");
 | |
| 298 | 	case EFsBlockMap: return _L("EFsBlockMap");
 | |
| 299 | 	case EFsUnclamp: return _L("EFsUnclamp");
 | |
| 300 | 	case EFsFileClamp: return _L("EFsFileClamp");
 | |
| 301 | 	case EFsQueryVolumeInfoExt: return _L("EFsQueryVolumeInfoExt");
 | |
| 302 | 	case EFsInitialisePropertiesFile: return _L("EFsInitialisePropertiesFile");
 | |
| 303 | 	case EFsFileWriteDirty: return _L("EFsFileWriteDirty");
 | |
| 304 | 	case EFsSynchroniseDriveThread: return _L("EFsSynchroniseDriveThread");
 | |
| 305 | 	case EFsAddProxyDrive: return _L("EFsAddProxyDrive");
 | |
| 306 | 	case EFsRemoveProxyDrive: return _L("EFsRemoveProxyDrive");
 | |
| 307 | 	case EFsMountProxyDrive: return _L("EFsMountProxyDrive");
 | |
| 308 | 	case EFsDismountProxyDrive:  return _L("EFsDismountProxyDrive");
 | |
| 309 | 	case EFsNotificationAdd : return _L("EFsNotificationAdd"); 
 | |
| 310 | 	case EFsNotificationBuffer : return _L("EFsNotificationBuffer");
 | |
| 311 | 	case EFsNotificationCancel : return _L("EFsNotificationCancel");
 | |
| 312 | 	case EFsNotificationOpen : return _L("EFsNotificationOpen");
 | |
| 313 | 	case EFsNotificationRemove : return _L("EFsNotificationRemove");
 | |
| 314 | 	case EFsNotificationRequest : return _L("EFsNotificationRequest");
 | |
| 315 | 	case EFsNotificationSubClose : return _L("EFsNotificationSubClose");
 | |
| 316 | 	case EFsLoadCodePage: return _L("EFsLoadCodePage");
 | |
| 317 | default: | |
| 318 | 		return _L("Error unknown function");
 | |
| 319 | } | |
| 320 | } | |
| 321 | ||
| 322 | ||
| 323 | void PrintStartUpReason(TMachineStartupType aReason) | |
| 324 | // | |
| 325 | // Print the reason the machine is booting up | |
| 326 | // | |
| 327 | 	{
 | |
| 328 | ||
| 329 | TBuf<64> nameBuf; | |
| 330 | switch (aReason) | |
| 331 | 		{
 | |
| 332 | 	case EStartupCold: nameBuf=_L("EStartupCold"); break;
 | |
| 333 | 	case EStartupColdReset: nameBuf=_L("EStartupColdReset"); break;
 | |
| 334 | 	case EStartupNewOs: nameBuf=_L("EStartupNewOs"); break;
 | |
| 335 | 	case EStartupPowerFail: nameBuf=_L("StartupPowerFail"); break;
 | |
| 336 | 	case EStartupWarmReset: nameBuf=_L("EStartupWarmReset"); break;
 | |
| 337 | 	case EStartupKernelFault: nameBuf=_L("EStartupKernelFault"); break;
 | |
| 338 | 	case EStartupSafeReset: nameBuf=_L("EStartupSafeReset"); break;
 | |
| 339 | default: | |
| 340 | 		nameBuf=_L("Error unknown startup type");
 | |
| 341 | } | |
| 342 | 	__PRINT1(_L("Machine startup - %S"),&nameBuf);
 | |
| 343 | }; | |
| 344 | ||
| 345 | LOCAL_C void AllocPrint(TInt aFunction) | |
| 346 | // | |
| 347 | // Print number of alloc fails to complete a given function | |
| 348 | // | |
| 349 | 	{
 | |
| 350 | if (UserHeapAllocFailCount || KernHeapAllocFailCount) | |
| 351 | 		{	
 | |
| 352 | TPtrC funcName=GetFunctionName(aFunction); | |
| 353 | 			{
 | |
| 354 | 			__PRINTALLOC(_L("Function %S UserAllocs %d KernAllocs %d"),&funcName,UserHeapAllocFailCount,KernHeapAllocFailCount);
 | |
| 355 | } | |
| 356 | } | |
| 357 | } | |
| 358 | ||
| 359 | void SimulateAllocFailure(TInt aFunctionReturnValue,TInt aFunction) | |
| 360 | // | |
| 361 | // Simulate alloc failure | |
| 362 | // | |
| 363 | 	{
 | |
| 364 | ||
| 365 | ||
| 366 | if (UserHeapAllocFailCount>=0 && (aFunctionReturnValue==KErrDiskFull || aFunctionReturnValue==KErrNoMemory)) | |
| 367 | 		{
 | |
| 368 | if (KernHeapAllocFailCount<20) | |
| 369 | 			{
 | |
| 370 | __KHEAP_FAILNEXT(++KernHeapAllocFailCount); | |
| 371 | __UHEAP_FAILNEXT(UserHeapAllocFailCount); | |
| 372 | } | |
| 373 | else | |
| 374 | 			{
 | |
| 375 | KernHeapAllocFailCount=0; | |
| 376 | __UHEAP_FAILNEXT(++UserHeapAllocFailCount); | |
| 377 | __KHEAP_FAILNEXT(KernHeapAllocFailCount); | |
| 378 | } | |
| 379 | if (UserHeapAllocFailCount<100) | |
| 380 | return; | |
| 381 | } | |
| 382 | if (UserHeapAllocFailCount>=0) | |
| 383 | 		{
 | |
| 384 | AllocPrint(aFunction); | |
| 385 | UserHeapAllocFailCount=0; | |
| 386 | KernHeapAllocFailCount=0; | |
| 387 | __UHEAP_FAILNEXT(UserHeapAllocFailCount); | |
| 388 | __KHEAP_FAILNEXT(KernHeapAllocFailCount); | |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 392 | #else | |
| 393 | TInt FsDebugFunction(CFsRequest* /*aRequest*/) | |
| 394 | // | |
| 395 | // Not in the release build | |
| 396 | // | |
| 397 | 	{
 | |
| 398 | return KErrNotSupported; | |
| 399 | } | |
| 400 | #endif | |
| 401 | ||
| 402 | TInt TFsDebugFunc::DoRequestL(CFsRequest* aRequest) | |
| 403 | // | |
| 404 | // Not in the release build | |
| 405 | // | |
| 406 | 	{
 | |
| 407 | return FsDebugFunction(aRequest); | |
| 408 | } | |
| 409 | ||
| 410 | TInt TFsDebugFunc::Initialise(CFsRequest* /*aRequest*/) | |
| 411 | // | |
| 412 | // Not in the release build | |
| 413 | // | |
| 414 | 	{
 | |
| 415 | return KErrNone; | |
| 416 | } | |
| 417 | ||
| 418 | TInt TFsControlIo::DoRequestL(CFsRequest* aRequest) | |
| 419 | // | |
| 420 | // General purpose test interface - .FSY specific. | |
| 421 | // Not in the release build | |
| 422 | // | |
| 423 | 	{
 | |
| 424 | TInt command=aRequest->Message().Int1(); | |
| 425 | TAny* param1=(TAny*)aRequest->Message().Ptr2(); | |
| 426 | TAny* param2=(TAny*)aRequest->Message().Ptr3(); | |
| 427 | ||
| 428 | ||
| 429 | #if defined(_DEBUG) || defined(_DEBUG_RELEASE) | |
| 430 | switch(command) | |
| 431 | 		{	//These are non-drive commands
 | |
| 432 | case KControlIoGetCorruptLogRecord: | |
| 433 | 			{
 | |
| 434 | // number of the log record to be retrieved (1-based) | |
| 435 | TInt logRecNum=(TInt)param2; | |
| 436 | TFsDebugCorruptLogRecordBuf logBuf; | |
| 437 | TInt r=TCorruptLogRec::GetLogRecord(logBuf,logRecNum); | |
| 438 | if(r!=KErrNone) | |
| 439 | return r; | |
| 440 | r=aRequest->Write(2,logBuf,0); | |
| 441 | return r; | |
| 442 | } | |
| 443 | case KControlIoGetNumberOfCorruptLogRecords: | |
| 444 | 			{
 | |
| 445 | TPtrC8 ptrHits((TUint8*)&gNumberOfCorruptHits,sizeof(gNumberOfCorruptHits)); | |
| 446 | TInt r=aRequest->Write(2,ptrHits,0); | |
| 447 | ||
| 448 | return r; | |
| 449 | } | |
| 450 | case KControlIoGetCorruptListFile: | |
| 451 | 			{
 | |
| 452 | // Get name of file that contains the filenames nominated as "corrupt" | |
| 453 | TBuf8<KMaxFileName> fileName8; | |
| 454 | if(gCorruptFileNamesListFile) | |
| 455 | 				{
 | |
| 456 | fileName8.Copy(*gCorruptFileNamesListFile); | |
| 457 | } | |
| 458 | else | |
| 459 | 				{
 | |
| 460 | fileName8.SetLength(0); | |
| 461 | } | |
| 462 | TInt r=aRequest->Write(2,fileName8,0); | |
| 463 | return r; | |
| 464 | } | |
| 465 | case KControlIoCorruptLogRecordReset: | |
| 466 | 			{
 | |
| 467 | TCorruptLogRec::DestroyList(); | |
| 468 | TCorruptNameRec::ResetListConsumed(); | |
| 469 | return KErrNone; | |
| 470 | } | |
| 471 | case KControlIoCacheCount: | |
| 472 | 			{
 | |
| 473 | TIOCacheValues cacheValues; | |
| 474 | cacheValues.iCloseCount= RequestAllocator::CloseCount(); | |
| 475 | cacheValues.iFreeCount= RequestAllocator::FreeCount(); | |
| 21 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 476 | cacheValues.iAllocated= 0; // no longer used | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 477 | cacheValues.iTotalCount= RequestAllocator::RequestCount(); | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 478 | cacheValues.iRequestCountPeak = RequestAllocator::RequestCountPeak(); | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 479 | |
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 480 | cacheValues.iOpFreeCount= OperationAllocator::FreeCount(); | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 481 | cacheValues.iOpRequestCount= OperationAllocator::RequestCount(); | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 482 | cacheValues.iOpRequestCountPeak = OperationAllocator::RequestCountPeak(); | 
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 483 | |
| 
e7d2d738d3c2
Revision: 201010
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
19diff
changeset | 484 | |
| 0 | 485 | TPckgBuf<TIOCacheValues> pkgBuf(cacheValues); | 
| 486 | ||
| 487 | // ensure we only write what the client buffer can hold - | |
| 488 | // this allows TIOCacheValues to increase in size without breaking BC | |
| 489 | pkgBuf.SetLength(Min(pkgBuf.MaxLength(), aRequest->Message().GetDesMaxLengthL(2))); | |
| 490 | ||
| 491 | TInt r=aRequest->Write(2,pkgBuf); | |
| 492 | return r; | |
| 493 | } | |
| 494 | case KControlIoGetLocalDriveNumber: | |
| 495 | 			{
 | |
| 496 | return DriveNumberToLocalDriveNumber(aRequest->Drive()->DriveNumber()); | |
| 497 | } | |
| 498 | case KControlIoCancelDeferredDismount: | |
| 499 | 			{
 | |
| 500 | // Cancel and clear deferred dismount information | |
| 501 | aRequest->Drive()->ClearDeferredDismount(); | |
| 502 | return KErrNone; | |
| 503 | } | |
| 504 | case KControlIoFileCacheStats: | |
| 505 | 			{
 | |
| 506 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | |
| 507 | if (manager == NULL) | |
| 508 | return KErrNotSupported; | |
| 509 | ||
| 510 | TFileCacheStats& stats = manager->Stats(); | |
| 511 | ||
| 512 | TPckgBuf<TFileCacheStats> pkgBuf(stats); | |
| 513 | TInt r=aRequest->Write(2,pkgBuf); | |
| 514 | return r; | |
| 515 | } | |
| 516 | case KControlIoFileCacheConfig: | |
| 517 | 			{
 | |
| 518 | TInt driveNumber = aRequest->Drive()->DriveNumber(); | |
| 519 | ||
| 520 | TFileCacheSettings::TFileCacheConfig* driveConfig = NULL; | |
| 521 | TInt r = TFileCacheSettings::GetFileCacheConfig(driveNumber, driveConfig); | |
| 522 | if (( r != KErrNone) || (driveConfig == NULL)) | |
| 523 | return KErrNotSupported; | |
| 524 | ||
| 525 | TFileCacheConfig config; | |
| 526 | config.iDrive = driveConfig->iDrive; | |
| 527 | config.iFlags = driveConfig->iFlags; | |
| 528 | config.iFileCacheReadAsync = driveConfig->iFileCacheReadAsync; | |
| 529 | config.iFairSchedulingLen = driveConfig->iFairSchedulingLen; | |
| 530 | config.iCacheSize = driveConfig->iCacheSize; | |
| 531 | config.iMaxReadAheadLen = driveConfig->iMaxReadAheadLen; | |
| 532 | config.iClosedFileKeepAliveTime = driveConfig->iClosedFileKeepAliveTime; | |
| 533 | config.iDirtyDataFlushTime = driveConfig->iDirtyDataFlushTime; | |
| 534 | ||
| 535 | TPckgBuf<TFileCacheConfig> pkgBuf(config); | |
| 536 | r=aRequest->Write(2,pkgBuf); | |
| 537 | return r; | |
| 538 | } | |
| 539 | case KControlIoFileCacheFlagsWrite: | |
| 540 | 			{
 | |
| 541 | TInt drive = aRequest->Message().Int0(); | |
| 542 | ||
| 543 | TPckgBuf<TFileCacheFlags> driveFlagsPkg; | |
| 544 | TFileCacheFlags& driveFlags = driveFlagsPkg(); | |
| 545 | ||
| 546 | TInt r = aRequest->Read(2, driveFlagsPkg); | |
| 547 | if (r != KErrNone) | |
| 548 | return r; | |
| 549 | ||
| 550 | 			__CACHE_PRINT2(_L("CACHE: TFileCacheFlags %x on drive %d"), driveFlags, drive);
 | |
| 551 | TFileCacheSettings::SetFlags(drive, driveFlags); | |
| 552 | ||
| 553 | return r; | |
| 554 | } | |
| 555 | case KControlIoFlushClosedFiles: | |
| 556 | 			{
 | |
| 557 | TClosedFileUtils::Remove(); | |
| 558 | return KErrNone; | |
| 559 | } | |
| 560 | case KControlIoSimulateLockFailureMode: | |
| 561 | 			{
 | |
| 562 | TPckgBuf<TBool> enabledPkg; | |
| 563 | TInt r = aRequest->Read(2, enabledPkg); | |
| 564 | if (r != KErrNone) | |
| 565 | return r; | |
| 566 | ||
| 567 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | |
| 568 | if (manager == NULL) | |
| 569 | return KErrNotSupported; | |
| 570 | manager->SimulateLockFailureMode(enabledPkg()); | |
| 571 | return KErrNone; | |
| 572 | } | |
| 573 | case KControlIoSimulateFileCacheWriteFailure: | |
| 574 | 			{
 | |
| 575 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | |
| 576 | if (manager == NULL) | |
| 577 | return KErrNotSupported; | |
| 578 | manager->SimulateWriteFailure(); | |
| 579 | return KErrNone; | |
| 580 | } | |
| 581 | case KControlIoFileCacheDump: | |
| 582 | 			{
 | |
| 583 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | |
| 584 | if (manager == NULL) | |
| 585 | return KErrNotSupported; | |
| 586 | manager->DumpCache(); | |
| 587 | return KErrNone; | |
| 588 | } | |
| 589 | case KControlIoAllocateMaxSegments: | |
| 590 | 			{
 | |
| 591 | TPckgBuf<TBool> enabledPkg; | |
| 592 | TInt r = aRequest->Read(2, enabledPkg); | |
| 593 | if (r != KErrNone) | |
| 594 | return r; | |
| 595 | ||
| 596 | CCacheManager* manager = CCacheManagerFactory::CacheManager(); | |
| 597 | if (manager == NULL) | |
| 598 | return KErrNotSupported; | |
| 599 | manager->AllocateMaxSegments(enabledPkg()); | |
| 600 | return KErrNone; | |
| 601 | } | |
| 602 | case KControlIoDisableFatUtilityFunctions: | |
| 603 | 			{
 | |
| 604 | EnableFatUtilityFunctions = EFalse; | |
| 605 | return KErrNone; | |
| 606 | } | |
| 607 | case KControlIoEnableFatUtilityFunctions: | |
| 608 | 			{
 | |
| 609 | EnableFatUtilityFunctions = ETrue; | |
| 610 | return KErrNone; | |
| 611 | } | |
| 19 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 612 | case KControlIoSessionCount: | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 613 |             {
 | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 614 | TPckgBuf<TInt> pkgBuf(SessionCount); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 615 | TInt r=aRequest->Write(2,pkgBuf); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 616 | return r; | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 617 | } | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 618 | case KControlIoObjectCount: | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 619 |             {
 | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 620 | TPckgBuf<TInt> pkgBuf(ObjectCount); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 621 | TInt r=aRequest->Write(2,pkgBuf); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 622 | return r; | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 623 | } | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 624 | |
| 0 | 625 | } | 
| 626 | #endif | |
| 627 | ||
| 628 | return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2)); | |
| 629 | } | |
| 630 | ||
| 631 | TInt TFsControlIo::Initialise(CFsRequest* aRequest) | |
| 632 | // | |
| 633 | // General purpose test interface - .FSY specific. | |
| 634 | // Not in the release build | |
| 635 | // | |
| 636 | 	{
 | |
| 637 | TInt driveNumber=aRequest->Message().Int0(); | |
| 638 | if(driveNumber<0||driveNumber>=KMaxDrives) | |
| 639 | return(KErrArgument); | |
| 640 | ValidateDriveDoSubst(driveNumber,aRequest); | |
| 641 | return KErrNone; | |
| 642 | } | |
| 643 |