1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_debug.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,600 @@
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\sfile\sf_debug.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include "sf_std.h"
1.22 +#include <f32dbg.h>
1.23 +#include "f32image.h"
1.24 +#include <F32plugin.h>
1.25 +#include "sf_file_cache.h"
1.26 +
1.27 +
1.28 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.29 +
1.30 +//
1.31 +// ONLY INCLUDED IN DEBUG BUILDS
1.32 +//
1.33 +
1.34 +void PrintHeapSize(const TDesC& aMessage)
1.35 +//
1.36 +// Display the total memory available
1.37 +//
1.38 + {
1.39 +
1.40 + TInt biggest;
1.41 + TInt heapSize = User::Allocator().Available(biggest);
1.42 + RDebug::Print(_L("%S size=0x%x largest cell=0x%x"),&aMessage,heapSize,biggest);
1.43 + }
1.44 +
1.45 +static void SetAllocFailure(const RMessage2* aMessage)
1.46 +//
1.47 +// Set alloc failure after allocCount allocations
1.48 +//
1.49 + {
1.50 +
1.51 + UserHeapAllocFailCount=aMessage->Int1();
1.52 + KernHeapAllocFailCount=UserHeapAllocFailCount;
1.53 + if (UserHeapAllocFailCount>=0)
1.54 + {
1.55 + __UHEAP_FAILNEXT(UserHeapAllocFailCount);
1.56 + __KHEAP_FAILNEXT(KernHeapAllocFailCount);
1.57 + }
1.58 + else
1.59 + {
1.60 + __UHEAP_RESET;
1.61 + __KHEAP_RESET;
1.62 + }
1.63 + }
1.64 +
1.65 +TInt FsDebugFunction(CFsRequest* aRequest)
1.66 +//
1.67 +// SetAllocFailure - Set alloc failure after allocCount allocations
1.68 +// SetErrorCondition - Set simulated error failure
1.69 +// SetDebugRegister - Trigger tracing output
1.70 +// DebugNotify - Request notification of a file server event - .FSY specific
1.71 +//
1.72 + {
1.73 +
1.74 + TInt r=KErrNone;
1.75 + const RMessage2* message=&(aRequest->Message());
1.76 + switch (message->Int0())
1.77 + {
1.78 + case EFsSetAllocFailure:
1.79 + SetAllocFailure(message);
1.80 + break;
1.81 + case EFsSetErrorCondition:
1.82 + ErrorCondition=message->Int1();
1.83 + ErrorCount=message->Int2();
1.84 + break;
1.85 + case EFsSetDebugRegister:
1.86 + DebugReg=message->Int1();
1.87 + break;
1.88 + case EFsDebugNotify:
1.89 + {
1.90 + TUint notifyType=(aRequest->Message().Int2())&KDebugNotifyMask;
1.91 + if (notifyType)
1.92 + {
1.93 + CDebugChangeInfo* info=new CDebugChangeInfo;
1.94 + if(!info)
1.95 + return(KErrNoMemory);
1.96 + const RMessage2& m=aRequest->Message();
1.97 + info->Initialise(notifyType,(TRequestStatus*)m.Ptr3(),m,aRequest->Session());
1.98 + r=FsNotify::AddDebug(info);
1.99 + if(r!=KErrNone)
1.100 + delete(info);
1.101 + else
1.102 + aRequest->SetCompleted(EFalse);
1.103 + }
1.104 + else
1.105 + r=KErrArgument;
1.106 + break;
1.107 + }
1.108 + default:
1.109 + break;
1.110 + };
1.111 + return(r);
1.112 + }
1.113 +
1.114 +TBool SimulateError(const RMessage2* aMessage)
1.115 +//
1.116 +// Return an error message if ErrorCount<=0
1.117 +//
1.118 + {
1.119 + TInt function = aMessage->Function() & KIpcFunctionMask;
1.120 +
1.121 + if (ErrorCondition!=KErrNone &&
1.122 + (
1.123 + function!=EFsDebugFunction || aMessage->Int0()!=EFsSetErrorCondition) &&
1.124 + function!=EFsNotifyChangeCancel &&
1.125 + function!=EFsNotifyChangeCancelEx &&
1.126 + function!=EFsNotifyDiskSpaceCancel &&
1.127 + function!=EFsFormatSubClose &&
1.128 + function!=EFsDirSubClose &&
1.129 + function!=EFsFileSubClose &&
1.130 + function!=EFsRawSubClose &&
1.131 + function!=EFsUnclamp &&
1.132 +
1.133 + //-- this operation must not fail. It can only fail if the client's thread has died.
1.134 + //-- in this case whole session will be cleaned up.
1.135 + function!=EFsFileAdopt
1.136 + )
1.137 + {
1.138 + if (ErrorCount<=0)
1.139 + return(ETrue);
1.140 + ErrorCount--;
1.141 + }
1.142 + return(EFalse);
1.143 + }
1.144 +
1.145 +
1.146 +TPtrC GetFunctionName(TInt aFunction)
1.147 +//
1.148 +// Print number of alloc fails to complete a given function
1.149 +//
1.150 + {
1.151 +
1.152 + switch (aFunction)
1.153 + {
1.154 + case EFsDebugFunction: return _L("EFsDebugFunction");
1.155 + case EFsAddFileSystem: return _L("EFsAddFileSystem");
1.156 + case EFsRemoveFileSystem: return _L("EFsRemoveFileSystem");
1.157 + case EFsMountFileSystem: return _L("EFsMountFileSystem");
1.158 + case EFsNotifyChange: return _L("EFsNotifyChange");
1.159 + case EFsNotifyChangeCancel: return _L("EFsNotifyChangeCancel");
1.160 + case EFsDriveList: return _L("EFsDriveList");
1.161 + case EFsDrive: return _L("EFsDrive");
1.162 + case EFsVolume: return _L("EFsVolume");
1.163 + case EFsSetVolume: return _L("EFsSetVolume");
1.164 + case EFsSubst: return _L("EFsSubst");
1.165 + case EFsSetSubst: return _L("EFsSetSubst");
1.166 + case EFsRealName: return _L("EFsRealName");
1.167 + case EFsDefaultPath: return _L("EFsDefaultPath");
1.168 + case EFsSetDefaultPath: return _L("EFsSetDefaultPath");
1.169 + case EFsSessionPath: return _L("EFsSessionPath");
1.170 + case EFsSetSessionPath: return _L("EFsSetSessionPath");
1.171 + case EFsMkDir: return _L("EFsMkDir");
1.172 + case EFsRmDir: return _L("EFsRmDir");
1.173 + case EFsParse: return _L("EFsParse");
1.174 + case EFsDelete: return _L("EFsDelete");
1.175 + case EFsRename: return _L("EFsRename");
1.176 + case EFsReplace: return _L("EFsReplace");
1.177 + case EFsEntry: return _L("EFsEntry");
1.178 + case EFsSetEntry: return _L("EFsSetEntry");
1.179 + case EFsGetDriveName: return _L("EFsGetDriveName");
1.180 + case EFsSetDriveName: return _L("EFsSetDriveName");
1.181 + case EFsFormatSubClose: return _L("EFsFormatSubClose");
1.182 + case EFsDirSubClose: return _L("EFsDirSubClose");
1.183 + case EFsFileSubClose: return _L("EFsFileSubClose");
1.184 + case EFsRawSubClose: return _L("EFsRawSubClose");
1.185 + case EFsFileOpen: return _L("EFsFileOpen");
1.186 + case EFsFileCreate: return _L("EFsFileCreate");
1.187 + case EFsFileReplace: return _L("EFsFileReplace");
1.188 + case EFsFileTemp: return _L("EFsFileTemp");
1.189 + case EFsFileRead: return _L("EFsFileRead");
1.190 + case EFsFileWrite: return _L("EFsFileWrite");
1.191 + case EFsFileLock: return _L("EFsFileLock");
1.192 + case EFsFileUnLock: return _L("EFsFileUnLock");
1.193 + case EFsFileSeek: return _L("EFsFileSeek");
1.194 + case EFsFileFlush: return _L("EFsFileFlush");
1.195 + case EFsFileSize: return _L("EFsFileSize");
1.196 + case EFsFileSetSize: return _L("EFsFileSetSize");
1.197 + case EFsFileAtt: return _L("EFsFileAtt");
1.198 + case EFsFileSetAtt: return _L("EFsFileSetAtt");
1.199 + case EFsFileModified: return _L("EFsFileModified");
1.200 + case EFsFileSetModified: return _L("EFsFileSetModified");
1.201 + case EFsFileSet: return _L("EFsFileSet");
1.202 + case EFsFileChangeMode: return _L("EFsFileChangeMode");
1.203 + case EFsFileRename: return _L("EFsFileRename");
1.204 + case EFsDirOpen: return _L("EFsDirOpen");
1.205 + case EFsDirReadOne: return _L("EFsDirReadOne");
1.206 + case EFsDirReadPacked: return _L("EFsDirReadPacked");
1.207 + case EFsFormatOpen: return _L("EFsFormatOpen");
1.208 + case EFsFormatNext: return _L("EFsFormatNext");
1.209 + case EFsRawDiskOpen: return _L("EFsRawDiskOpen");
1.210 + case EFsRawDiskRead: return _L("EFsRawDiskRead");
1.211 + case EFsRawDiskWrite: return _L("EFsRawDiskWrite");
1.212 + case EFsResourceCountMarkStart: return _L("EFsResourceCountMarkStart");
1.213 + case EFsResourceCountMarkEnd: return _L("EFsResourceCountMarkEnd");
1.214 + case EFsResourceCount: return _L("EFsResourceCount");
1.215 + case EFsCheckDisk: return _L("EFsCheckDisk");
1.216 + case EFsGetShortName: return _L("EFsGetShortName");
1.217 + case EFsGetLongName: return _L("EFsGetLongName");
1.218 + case EFsIsFileOpen: return _L("EFsIsFileOpen");
1.219 + case EFsListOpenFiles: return _L("EFsListOpenFiles");
1.220 + case EFsSetNotifyUser: return _L("EFsSetNotifyUser");
1.221 + case EFsIsFileInRom: return _L("EFsIsFileInRom");
1.222 + case EFsGetNotifyUser: return _L("EFsGetNotifyUser");
1.223 + case EFsIsValidName: return _L("EFsIsValidName");
1.224 + case EFsReadFileSection: return _L("EFsReadFileSection");
1.225 + case EFsNotifyChangeEx: return _L("EFsNotifyChangeEx");
1.226 + case EFsNotifyChangeCancelEx: return _L("EFsNotifyChangeCancelEx");
1.227 + case EFsDismountFileSystem: return _L("EFsDismountFileSystem");
1.228 + case EFsFileSystemName: return _L("EFsFileSystemName");
1.229 + case EFsScanDrive: return _L("EFsScanDrive");
1.230 + case EFsControlIo: return _L("EFsControlIo");
1.231 + case EFsLockDrive: return _L("EFsLockDrive");
1.232 + case EFsUnlockDrive: return _L("EFsUnlockDrive");
1.233 + case EFsClearPassword: return _L("EFsClearPassword");
1.234 + case EFsNotifyDiskSpace: return _L("EFsNotifyDiskSpace");
1.235 + case EFsNotifyDiskSpaceCancel: return _L("EFsNotifyDiskSpaceCancel");
1.236 + case EFsMountFileSystemScan: return _L("EFsMountFileSystemScan");
1.237 + case EFsSessionToPrivate: return _L("EFsSessionToPrivate");
1.238 + case EFsPrivatePath: return _L("EFsPrivatePath");
1.239 + case EFsCreatePrivatePath: return _L("EFsCreatePrivatePath");
1.240 + case EFsFileDrive: return _L("EFsFileDrive");
1.241 + case EFsRemountDrive: return _L("EFsRemountDrive");
1.242 + case EFsAddExtension: return _L("EFsAddExtension");
1.243 + case EFsMountExtension: return _L("EFsMountExtension");
1.244 + case EFsDismountExtension: return _L("EFsDismountExtension");
1.245 + case EFsRemoveExtension: return _L("EFsRemoveExtension");
1.246 + case EFsExtensionName: return _L("EFsExtensionName");
1.247 + case EFsStartupInitComplete: return _L("EFsStartupInitComplete");
1.248 + case EFsSetLocalDriveMapping: return _L("EFsSetLocalDriveMapping");
1.249 + case EFsFileDuplicate: return _L("EFsFileDuplicate");
1.250 + case EFsFileAdopt: return _L("EFsFileAdopt");
1.251 + case EFsFinaliseDrive: return _L("EFsFinaliseDrive");
1.252 + case EFsSwapFileSystem: return _L("EFsSwapFileSystem");
1.253 + case EFsErasePassword: return _L("EFsErasePassword");
1.254 + case EFsReserveDriveSpace: return _L("EFsReserveDriveSpace");
1.255 + case EFsGetReserveAccess: return _L("EFsGetReserveAccess");
1.256 + case EFsReleaseReserveAccess: return _L("EFsReleaseReserveAccess");
1.257 + case EFsFileName: return _L("EFsFileName");
1.258 + case EFsGetMediaSerialNumber: return _L("EFsGetMediaSerialNumber");
1.259 + case EFsFileFullName: return _L("EFsFileFullName");
1.260 + case EFsAddPlugin: return _L("EFsAddPlugin");
1.261 + case EFsRemovePlugin: return _L("EFsRemovePlugin");
1.262 + case EFsMountPlugin: return _L("EFsMountPlugin");
1.263 + case EFsDismountPlugin: return _L("EFsDismountPlugin");
1.264 + case EFsPluginName: return _L("EFsPluginName");
1.265 + case EFsPluginOpen: return _L("EFsPluginOpen");
1.266 + case EFsPluginSubClose: return _L("EFsPluginSubClose");
1.267 + case EFsPluginDoRequest: return _L("EFsPluginDoRequest");
1.268 + case EFsPluginDoControl: return _L("EFsPluginDoControl");
1.269 + case EFsPluginDoCancel: return _L("EFsPluginDoCancel");
1.270 + case EFsNotifyDismount: return _L("EFsNotifyDismount");
1.271 + case EFsNotifyDismountCancel: return _L("EFsNotifyDismountCancel");
1.272 + case EFsAllowDismount: return _L("EFsAllowDismount");
1.273 + case EFsSetStartupConfiguration: return _L("EFsSetStartupConfiguration");
1.274 + case EFsFileReadCancel: return _L("EFsFileReadCancel");
1.275 + case EFsAddCompositeMount: return _L("EFsAddCompositeMount");
1.276 + case EFsSetSessionFlags: return _L("EFsSetSessionFlags");
1.277 + case EFsSetSystemDrive: return _L("EFsSetSystemDrive");
1.278 + case EFsBlockMap: return _L("EFsBlockMap");
1.279 + case EFsUnclamp: return _L("EFsUnclamp");
1.280 + case EFsFileClamp: return _L("EFsFileClamp");
1.281 + case EFsQueryVolumeInfoExt: return _L("EFsQueryVolumeInfoExt");
1.282 + case EFsInitialisePropertiesFile: return _L("EFsInitialisePropertiesFile");
1.283 + case EFsFileWriteDirty: return _L("EFsFileWriteDirty");
1.284 + case EFsSynchroniseDriveThread: return _L("EFsSynchroniseDriveThread");
1.285 + case EFsAddProxyDrive: return _L("EFsAddProxyDrive");
1.286 + case EFsRemoveProxyDrive: return _L("EFsRemoveProxyDrive");
1.287 + case EFsMountProxyDrive: return _L("EFsMountProxyDrive");
1.288 + case EFsDismountProxyDrive: return _L("EFsDismountProxyDrive");
1.289 + case EFsNotificationAdd : return _L("EFsNotificationAdd");
1.290 + case EFsNotificationBuffer : return _L("EFsNotificationBuffer");
1.291 + case EFsNotificationCancel : return _L("EFsNotificationCancel");
1.292 + case EFsNotificationOpen : return _L("EFsNotificationOpen");
1.293 + case EFsNotificationRemove : return _L("EFsNotificationRemove");
1.294 + case EFsNotificationRequest : return _L("EFsNotificationRequest");
1.295 + case EFsNotificationSubClose : return _L("EFsNotificationSubClose");
1.296 + case EFsLoadCodePage: return _L("EFsLoadCodePage");
1.297 + default:
1.298 + return _L("Error unknown function");
1.299 + }
1.300 + }
1.301 +
1.302 +
1.303 +void PrintStartUpReason(TMachineStartupType aReason)
1.304 +//
1.305 +// Print the reason the machine is booting up
1.306 +//
1.307 + {
1.308 +
1.309 + TBuf<64> nameBuf;
1.310 + switch (aReason)
1.311 + {
1.312 + case EStartupCold: nameBuf=_L("EStartupCold"); break;
1.313 + case EStartupColdReset: nameBuf=_L("EStartupColdReset"); break;
1.314 + case EStartupNewOs: nameBuf=_L("EStartupNewOs"); break;
1.315 + case EStartupPowerFail: nameBuf=_L("StartupPowerFail"); break;
1.316 + case EStartupWarmReset: nameBuf=_L("EStartupWarmReset"); break;
1.317 + case EStartupKernelFault: nameBuf=_L("EStartupKernelFault"); break;
1.318 + case EStartupSafeReset: nameBuf=_L("EStartupSafeReset"); break;
1.319 + default:
1.320 + nameBuf=_L("Error unknown startup type");
1.321 + }
1.322 + __PRINT1(_L("Machine startup - %S"),&nameBuf);
1.323 + };
1.324 +
1.325 +LOCAL_C void AllocPrint(TInt aFunction)
1.326 +//
1.327 +// Print number of alloc fails to complete a given function
1.328 +//
1.329 + {
1.330 + if (UserHeapAllocFailCount || KernHeapAllocFailCount)
1.331 + {
1.332 + TPtrC funcName=GetFunctionName(aFunction);
1.333 + {
1.334 + __PRINTALLOC(_L("Function %S UserAllocs %d KernAllocs %d"),&funcName,UserHeapAllocFailCount,KernHeapAllocFailCount);
1.335 + }
1.336 + }
1.337 + }
1.338 +
1.339 +void SimulateAllocFailure(TInt aFunctionReturnValue,TInt aFunction)
1.340 +//
1.341 +// Simulate alloc failure
1.342 +//
1.343 + {
1.344 +
1.345 +
1.346 + if (UserHeapAllocFailCount>=0 && (aFunctionReturnValue==KErrDiskFull || aFunctionReturnValue==KErrNoMemory))
1.347 + {
1.348 + if (KernHeapAllocFailCount<20)
1.349 + {
1.350 + __KHEAP_FAILNEXT(++KernHeapAllocFailCount);
1.351 + __UHEAP_FAILNEXT(UserHeapAllocFailCount);
1.352 + }
1.353 + else
1.354 + {
1.355 + KernHeapAllocFailCount=0;
1.356 + __UHEAP_FAILNEXT(++UserHeapAllocFailCount);
1.357 + __KHEAP_FAILNEXT(KernHeapAllocFailCount);
1.358 + }
1.359 + if (UserHeapAllocFailCount<100)
1.360 + return;
1.361 + }
1.362 + if (UserHeapAllocFailCount>=0)
1.363 + {
1.364 + AllocPrint(aFunction);
1.365 + UserHeapAllocFailCount=0;
1.366 + KernHeapAllocFailCount=0;
1.367 + __UHEAP_FAILNEXT(UserHeapAllocFailCount);
1.368 + __KHEAP_FAILNEXT(KernHeapAllocFailCount);
1.369 + }
1.370 + }
1.371 +
1.372 +#else
1.373 +TInt FsDebugFunction(CFsRequest* /*aRequest*/)
1.374 +//
1.375 +// Not in the release build
1.376 +//
1.377 + {
1.378 + return KErrNotSupported;
1.379 + }
1.380 +#endif
1.381 +
1.382 +TInt TFsDebugFunc::DoRequestL(CFsRequest* aRequest)
1.383 +//
1.384 +// Not in the release build
1.385 +//
1.386 + {
1.387 + return FsDebugFunction(aRequest);
1.388 + }
1.389 +
1.390 +TInt TFsDebugFunc::Initialise(CFsRequest* /*aRequest*/)
1.391 +//
1.392 +// Not in the release build
1.393 +//
1.394 + {
1.395 + return KErrNone;
1.396 + }
1.397 +
1.398 +TInt TFsControlIo::DoRequestL(CFsRequest* aRequest)
1.399 +//
1.400 +// General purpose test interface - .FSY specific.
1.401 +// Not in the release build
1.402 +//
1.403 + {
1.404 + TInt command=aRequest->Message().Int1();
1.405 + TAny* param1=(TAny*)aRequest->Message().Ptr2();
1.406 + TAny* param2=(TAny*)aRequest->Message().Ptr3();
1.407 +
1.408 +
1.409 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
1.410 + switch(command)
1.411 + { //These are non-drive commands
1.412 + case KControlIoGetCorruptLogRecord:
1.413 + {
1.414 + // number of the log record to be retrieved (1-based)
1.415 + TInt logRecNum=(TInt)param2;
1.416 + TFsDebugCorruptLogRecordBuf logBuf;
1.417 + TInt r=TCorruptLogRec::GetLogRecord(logBuf,logRecNum);
1.418 + if(r!=KErrNone)
1.419 + return r;
1.420 + r=aRequest->Write(2,logBuf,0);
1.421 + return r;
1.422 + }
1.423 + case KControlIoGetNumberOfCorruptLogRecords:
1.424 + {
1.425 + TPtrC8 ptrHits((TUint8*)&gNumberOfCorruptHits,sizeof(gNumberOfCorruptHits));
1.426 + TInt r=aRequest->Write(2,ptrHits,0);
1.427 +
1.428 + return r;
1.429 + }
1.430 + case KControlIoGetCorruptListFile:
1.431 + {
1.432 + // Get name of file that contains the filenames nominated as "corrupt"
1.433 + TBuf8<KMaxFileName> fileName8;
1.434 + if(gCorruptFileNamesListFile)
1.435 + {
1.436 + fileName8.Copy(*gCorruptFileNamesListFile);
1.437 + }
1.438 + else
1.439 + {
1.440 + fileName8.SetLength(0);
1.441 + }
1.442 + TInt r=aRequest->Write(2,fileName8,0);
1.443 + return r;
1.444 + }
1.445 + case KControlIoCorruptLogRecordReset:
1.446 + {
1.447 + TCorruptLogRec::DestroyList();
1.448 + TCorruptNameRec::ResetListConsumed();
1.449 + return KErrNone;
1.450 + }
1.451 + case KControlIoCacheCount:
1.452 + {
1.453 + TIOCacheValues cacheValues;
1.454 + cacheValues.iCloseCount= RequestAllocator::CloseCount();
1.455 + cacheValues.iFreeCount= RequestAllocator::FreeCount();
1.456 + cacheValues.iAllocated= RequestAllocator::AllocatedCount();
1.457 + cacheValues.iTotalCount= RequestAllocator::TotalCount();
1.458 + TPckgBuf<TIOCacheValues> pkgBuf(cacheValues);
1.459 +
1.460 + // ensure we only write what the client buffer can hold -
1.461 + // this allows TIOCacheValues to increase in size without breaking BC
1.462 + pkgBuf.SetLength(Min(pkgBuf.MaxLength(), aRequest->Message().GetDesMaxLengthL(2)));
1.463 +
1.464 + TInt r=aRequest->Write(2,pkgBuf);
1.465 + return r;
1.466 + }
1.467 + case KControlIoGetLocalDriveNumber:
1.468 + {
1.469 + return DriveNumberToLocalDriveNumber(aRequest->Drive()->DriveNumber());
1.470 + }
1.471 + case KControlIoCancelDeferredDismount:
1.472 + {
1.473 + // Cancel and clear deferred dismount information
1.474 + aRequest->Drive()->ClearDeferredDismount();
1.475 + return KErrNone;
1.476 + }
1.477 + case KControlIoFileCacheStats:
1.478 + {
1.479 + CCacheManager* manager = CCacheManagerFactory::CacheManager();
1.480 + if (manager == NULL)
1.481 + return KErrNotSupported;
1.482 +
1.483 + TFileCacheStats& stats = manager->Stats();
1.484 +
1.485 + TPckgBuf<TFileCacheStats> pkgBuf(stats);
1.486 + TInt r=aRequest->Write(2,pkgBuf);
1.487 + return r;
1.488 + }
1.489 + case KControlIoFileCacheConfig:
1.490 + {
1.491 + TInt driveNumber = aRequest->Drive()->DriveNumber();
1.492 +
1.493 + TFileCacheSettings::TFileCacheConfig* driveConfig = NULL;
1.494 + TInt r = TFileCacheSettings::GetFileCacheConfig(driveNumber, driveConfig);
1.495 + if (( r != KErrNone) || (driveConfig == NULL))
1.496 + return KErrNotSupported;
1.497 +
1.498 + TFileCacheConfig config;
1.499 + config.iDrive = driveConfig->iDrive;
1.500 + config.iFlags = driveConfig->iFlags;
1.501 + config.iFileCacheReadAsync = driveConfig->iFileCacheReadAsync;
1.502 + config.iFairSchedulingLen = driveConfig->iFairSchedulingLen;
1.503 + config.iCacheSize = driveConfig->iCacheSize;
1.504 + config.iMaxReadAheadLen = driveConfig->iMaxReadAheadLen;
1.505 + config.iClosedFileKeepAliveTime = driveConfig->iClosedFileKeepAliveTime;
1.506 + config.iDirtyDataFlushTime = driveConfig->iDirtyDataFlushTime;
1.507 +
1.508 + TPckgBuf<TFileCacheConfig> pkgBuf(config);
1.509 + r=aRequest->Write(2,pkgBuf);
1.510 + return r;
1.511 + }
1.512 + case KControlIoFileCacheFlagsWrite:
1.513 + {
1.514 + TInt drive = aRequest->Message().Int0();
1.515 +
1.516 + TPckgBuf<TFileCacheFlags> driveFlagsPkg;
1.517 + TFileCacheFlags& driveFlags = driveFlagsPkg();
1.518 +
1.519 + TInt r = aRequest->Read(2, driveFlagsPkg);
1.520 + if (r != KErrNone)
1.521 + return r;
1.522 +
1.523 + __CACHE_PRINT2(_L("CACHE: TFileCacheFlags %x on drive %d"), driveFlags, drive);
1.524 + TFileCacheSettings::SetFlags(drive, driveFlags);
1.525 +
1.526 + return r;
1.527 + }
1.528 + case KControlIoFlushClosedFiles:
1.529 + {
1.530 + TClosedFileUtils::Remove();
1.531 + return KErrNone;
1.532 + }
1.533 + case KControlIoSimulateLockFailureMode:
1.534 + {
1.535 + TPckgBuf<TBool> enabledPkg;
1.536 + TInt r = aRequest->Read(2, enabledPkg);
1.537 + if (r != KErrNone)
1.538 + return r;
1.539 +
1.540 + CCacheManager* manager = CCacheManagerFactory::CacheManager();
1.541 + if (manager == NULL)
1.542 + return KErrNotSupported;
1.543 + manager->SimulateLockFailureMode(enabledPkg());
1.544 + return KErrNone;
1.545 + }
1.546 + case KControlIoSimulateFileCacheWriteFailure:
1.547 + {
1.548 + CCacheManager* manager = CCacheManagerFactory::CacheManager();
1.549 + if (manager == NULL)
1.550 + return KErrNotSupported;
1.551 + manager->SimulateWriteFailure();
1.552 + return KErrNone;
1.553 + }
1.554 + case KControlIoFileCacheDump:
1.555 + {
1.556 + CCacheManager* manager = CCacheManagerFactory::CacheManager();
1.557 + if (manager == NULL)
1.558 + return KErrNotSupported;
1.559 + manager->DumpCache();
1.560 + return KErrNone;
1.561 + }
1.562 + case KControlIoAllocateMaxSegments:
1.563 + {
1.564 + TPckgBuf<TBool> enabledPkg;
1.565 + TInt r = aRequest->Read(2, enabledPkg);
1.566 + if (r != KErrNone)
1.567 + return r;
1.568 +
1.569 + CCacheManager* manager = CCacheManagerFactory::CacheManager();
1.570 + if (manager == NULL)
1.571 + return KErrNotSupported;
1.572 + manager->AllocateMaxSegments(enabledPkg());
1.573 + return KErrNone;
1.574 + }
1.575 + case KControlIoDisableFatUtilityFunctions:
1.576 + {
1.577 + EnableFatUtilityFunctions = EFalse;
1.578 + return KErrNone;
1.579 + }
1.580 + case KControlIoEnableFatUtilityFunctions:
1.581 + {
1.582 + EnableFatUtilityFunctions = ETrue;
1.583 + return KErrNone;
1.584 + }
1.585 + }
1.586 +#endif
1.587 +
1.588 + return(aRequest->Drive()->ControlIO(aRequest->Message(),command,param1,param2));
1.589 + }
1.590 +
1.591 +TInt TFsControlIo::Initialise(CFsRequest* aRequest)
1.592 +//
1.593 +// General purpose test interface - .FSY specific.
1.594 +// Not in the release build
1.595 +//
1.596 + {
1.597 + TInt driveNumber=aRequest->Message().Int0();
1.598 + if(driveNumber<0||driveNumber>=KMaxDrives)
1.599 + return(KErrArgument);
1.600 + ValidateDriveDoSubst(driveNumber,aRequest);
1.601 + return KErrNone;
1.602 + }
1.603 +