| author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> | 
| Sat, 20 Feb 2010 00:10:51 +0200 | |
| branch | RCL_3 | 
| changeset 19 | 4a8fed1c0ef6 | 
| parent 0 | a41df078684a | 
| permissions | -rw-r--r-- | 
| 0 | 1 | // Copyright (c) 1995-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_ses.cpp | |
| 15 | // | |
| 16 | // | |
| 17 | ||
| 18 | #include "sf_std.h" | |
| 19 | #include "sf_file_cache.h" | |
| 20 | #include "sf_memory_man.h" | |
| 21 | #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION | |
| 22 | #include "sf_notifier.h" | |
| 23 | #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION | |
| 24 | ||
| 25 | CSessionFs::CSessionFs() | |
| 26 | :iSessionFlags((TInt)EFsSessionFlagsAll), | |
| 27 | iReservedDriveAccess(KReservedDriveAccessArrayGranularity, _FOFF(TReservedDriveAccess, iDriveNumber)), | |
| 28 | iId(0) | |
| 29 | 	{
 | |
| 19 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 30 | #if defined(_DEBUG) || defined(_DEBUG_RELEASE) | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 31 | __e32_atomic_add_ord32(&SessionCount, 1); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 32 | #endif | 
| 0 | 33 | } | 
| 34 | ||
| 35 | CSessionFs *CSessionFs::NewL() | |
| 36 | 	{
 | |
| 37 | return new(ELeave) CSessionFs; | |
| 38 | } | |
| 39 | ||
| 40 | CSessionFs::~CSessionFs() | |
| 41 | 	{
 | |
| 42 | 	__PRINT1(_L("CSessionFs::~CSessionFs() deleting... = 0x%x"),this);
 | |
| 43 | ||
| 44 | //take out all the reserved space set by this session | |
| 45 | while(iReservedDriveAccess.Count()) | |
| 46 | 		{
 | |
| 47 | TReservedDriveAccess& reserved = iReservedDriveAccess[0]; | |
| 48 | if(reserved.iReservedSpace) | |
| 49 | 			{
 | |
| 50 | TheDrives[reserved.iDriveNumber].SetReservedSpace(TheDrives[reserved.iDriveNumber].ReservedSpace() - reserved.iReservedSpace); | |
| 51 | __ASSERT_DEBUG(TheDrives[reserved.iDriveNumber].ReservedSpace() >= 0,Fault(EReserveSpaceArithmetic)); | |
| 52 | } | |
| 53 | iReservedDriveAccess.Remove(0); | |
| 54 | } | |
| 55 | iReservedDriveAccess.Close(); | |
| 56 | ||
| 57 | ||
| 58 | // Need to free the requests that we own from the close queue | |
| 59 | while (iCloseRequestCount > 0) | |
| 60 | RequestAllocator::OpenSubFailed(this); | |
| 61 | ||
| 62 | if (iHandles) | |
| 63 | delete iHandles; | |
| 64 | ||
| 65 | ||
| 66 | delete iPath; | |
| 67 | iSessionFlagsLock.Close(); | |
| 68 | if(iDisconnectRequest) | |
| 69 | delete(iDisconnectRequest); | |
| 19 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 70 | |
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 71 | #if defined(_DEBUG) || defined(_DEBUG_RELEASE) | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 72 | __e32_atomic_add_ord32(&SessionCount, (TUint32) -1); | 
| 
4a8fed1c0ef6
Revision: 201007
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
0diff
changeset | 73 | #endif | 
| 0 | 74 | } | 
| 75 | ||
| 76 | void CSessionFs::CreateL() | |
| 77 | // | |
| 78 | // Create any additional resources. | |
| 79 | // | |
| 80 | 	{
 | |
| 81 | 	__PRINT1(_L("CSessionFs::CreateL 0x%x"),this);
 | |
| 82 | ||
| 83 | iHandles=CFsObjectIx::NewL(); | |
| 84 | TInt r = iSessionFlagsLock.CreateLocal(); | |
| 85 | User::LeaveIfError(r); | |
| 86 | RMessage2 m; | |
| 87 | ||
| 88 | iDisconnectRequest=new(ELeave) CFsDisconnectRequest; | |
| 89 | iDisconnectRequest->Set(m,SessionDisconnectOp,this); | |
| 90 | ||
| 91 | ||
| 92 | } | |
| 93 | ||
| 94 | TInt CSessionFs::CurrentDrive() | |
| 95 | // | |
| 96 | // Return the current drive. | |
| 97 | // | |
| 98 | 	{
 | |
| 99 | ||
| 100 | TInt d; | |
| 101 | TInt r=RFs::CharToDrive(Path()[0],d); | |
| 102 | __ASSERT_ALWAYS(r==KErrNone,Fault(ESesPathBadDrive)); | |
| 103 | return(d); | |
| 104 | } | |
| 105 | ||
| 106 | TInt CSessionFs::CountResources() | |
| 107 | // | |
| 108 | // Return the number of resources owned by the session | |
| 109 | // | |
| 110 | 	{
 | |
| 111 | /* what's this supposed to be doing ?? | |
| 112 | TInt count=User::LockedInc(iResourceCount); | |
| 113 | User::LockedDec(iResourceCount); | |
| 114 | return(count); | |
| 115 | */ | |
| 116 | ||
| 117 | return iResourceCount; // ... because that's all it does. | |
| 118 | } | |
| 119 | ||
| 120 | void CSessionFs::ResourceCountMarkStart() | |
| 121 | // | |
| 122 | // Mark resources at this point | |
| 123 | // | |
| 124 | 	{
 | |
| 125 | iResourceCountMark = CountResources(); | |
| 126 | } | |
| 127 | ||
| 128 | void CSessionFs::ResourceCountMarkEnd(const RMessage2& aMessage) | |
| 129 | // | |
| 130 | // End resource count and check same as count start | |
| 131 | // | |
| 132 | 	{
 | |
| 133 | if (iResourceCountMark!=CountResources()) | |
| 134 | 		{
 | |
| 135 | _LIT(KCategory,"CSessionFs"); | |
| 136 | aMessage.Panic(KCategory,ESesFoundResCountHeaven); | |
| 137 | } | |
| 138 | else | |
| 139 | aMessage.Complete(KErrNone); | |
| 140 | } | |
| 141 | ||
| 142 | void CSessionFs::Disconnect(const RMessage2& aMessage) | |
| 143 | 	{
 | |
| 144 | 	__THRD_PRINT1(_L("CSessionFs::Disconnect() 0x%x"),this);
 | |
| 145 | ||
| 146 | iHandles->CloseMainThreadObjects(); | |
| 147 | iDisconnectRequest->SetMessage((RMessage2&)aMessage); | |
| 148 | ||
| 149 | iDisconnectRequest->Dispatch(); | |
| 150 | } | |
| 151 | ||
| 152 | ||
| 153 | TUint CSessionFs::Reserved(TInt aDriveNumber) const | |
| 154 | 	{
 | |
| 155 | TReservedDriveAccess reserved(aDriveNumber); | |
| 156 | TInt idx = iReservedDriveAccess.Find(reserved); | |
| 157 | if(idx == KErrNotFound) | |
| 158 | return 0; | |
| 159 | ||
| 160 | return iReservedDriveAccess[idx].iReservedSpace; | |
| 161 | } | |
| 162 | ||
| 163 | ||
| 164 | TInt CSessionFs::SetReserved(const TInt aDriveNumber, const TInt aReservedValue) | |
| 165 | 	{
 | |
| 166 | TReservedDriveAccess reserved(aDriveNumber, aReservedValue); | |
| 167 | TInt idx = iReservedDriveAccess.Find(reserved); | |
| 168 | if(idx == KErrNotFound) | |
| 169 | return iReservedDriveAccess.InsertInSignedKeyOrder(reserved); | |
| 170 | ||
| 171 | iReservedDriveAccess[idx].iReservedSpace = aReservedValue; | |
| 172 | return KErrNone; | |
| 173 | ||
| 174 | } | |
| 175 | ||
| 176 | ||
| 177 | TBool CSessionFs::ReservedAccess(TInt aDriveNumber) const | |
| 178 | 	{
 | |
| 179 | TReservedDriveAccess reserved(aDriveNumber); | |
| 180 | TInt idx = iReservedDriveAccess.Find(reserved); | |
| 181 | return idx == KErrNotFound ? EFalse : iReservedDriveAccess[idx].iReservedAccess; | |
| 182 | } | |
| 183 | ||
| 184 | ||
| 185 | void CSessionFs::SetReservedAccess(const TInt aDriveNumber, const TBool aReservedAccess) | |
| 186 | 	{
 | |
| 187 | TReservedDriveAccess reserved(aDriveNumber); | |
| 188 | TInt idx = iReservedDriveAccess.Find(reserved); | |
| 189 | if(idx != KErrNotFound) | |
| 190 | iReservedDriveAccess[idx].iReservedAccess = aReservedAccess; | |
| 191 | } | |
| 192 | ||
| 193 | TBool CSessionFs::IsChangeNotify() | |
| 194 | 	{
 | |
| 195 | return TestSessionFlags(EFsSessionNotifyChange); | |
| 196 | } | |
| 197 | ||
| 198 | ||
| 199 | TBool CSessionFs::TestSessionFlags(TUint32 aFlags) | |
| 200 | 	{
 | |
| 201 | iSessionFlagsLock.Wait(); | |
| 202 | TBool b = (iSessionFlags & aFlags) == aFlags; | |
| 203 | iSessionFlagsLock.Signal(); | |
| 204 | return(b); | |
| 205 | } | |
| 206 | ||
| 207 | ||
| 208 | void CSessionFs::SetSessionFlags(TUint32 aBitsToSet, TUint32 aBitsToClear) | |
| 209 | 	{
 | |
| 210 | iSessionFlagsLock.Wait(); | |
| 211 | ||
| 212 | iSessionFlags &= ~aBitsToClear; | |
| 213 | iSessionFlags |= aBitsToSet; | |
| 214 | ||
| 215 | iSessionFlagsLock.Signal(); | |
| 216 | } | |
| 217 | ||
| 218 | void CSessionFs::CloseRequestCountInc() | |
| 219 | 	{
 | |
| 220 | iSessionFlagsLock.Wait(); | |
| 221 | iCloseRequestCount++; | |
| 222 | iSessionFlagsLock.Signal(); | |
| 223 | } | |
| 224 | ||
| 225 | void CSessionFs::CloseRequestCountDec() | |
| 226 | 	{
 | |
| 227 | iSessionFlagsLock.Wait(); | |
| 228 | iCloseRequestCount--; | |
| 229 | iSessionFlagsLock.Signal(); | |
| 230 | } | |
| 231 | ||
| 232 | // | |
| 233 | // Start resource count | |
| 234 | // | |
| 235 | TInt TFsResourceCountMarkStart::DoRequestL(CFsRequest* aRequest) | |
| 236 | 	{
 | |
| 237 | aRequest->Session()->ResourceCountMarkStart(); | |
| 238 | return(KErrNone); | |
| 239 | } | |
| 240 | ||
| 241 | TInt TFsResourceCountMarkStart::Initialise(CFsRequest* /*aRequest*/) | |
| 242 | 	{
 | |
| 243 | return KErrNone; | |
| 244 | } | |
| 245 | ||
| 246 | ||
| 247 | // | |
| 248 | // Check for resource heaven | |
| 249 | // | |
| 250 | TInt TFsResourceCountMarkEnd::DoRequestL(CFsRequest* aRequest) | |
| 251 | 	{
 | |
| 252 | aRequest->Session()->ResourceCountMarkEnd(aRequest->Message()); | |
| 253 | return(KErrNone); | |
| 254 | } | |
| 255 | ||
| 256 | TInt TFsResourceCountMarkEnd::Initialise(CFsRequest* /*aRequest*/) | |
| 257 | 	{
 | |
| 258 | return KErrNone; | |
| 259 | } | |
| 260 | ||
| 261 | ||
| 262 | // | |
| 263 | // Return the number of resources owned by the session | |
| 264 | // | |
| 265 | TInt TFsResourceCount::DoRequestL(CFsRequest* aRequest) | |
| 266 | 	{
 | |
| 267 | TInt resCount=aRequest->Session()->CountResources(); | |
| 268 | TPckgC<TInt> pckg(resCount); | |
| 269 | aRequest->WriteL(KMsgPtr0,pckg); | |
| 270 | return(KErrNone); | |
| 271 | } | |
| 272 | ||
| 273 | TInt TFsResourceCount::Initialise(CFsRequest* /*aRequest*/) | |
| 274 | 	{
 | |
| 275 | return KErrNone; | |
| 276 | } | |
| 277 | ||
| 278 | ||
| 279 | // | |
| 280 | // Set iNotifyUser | |
| 281 | // | |
| 282 | void CSessionFs::SetNotifyUser(TBool aNotification) | |
| 283 | 	{
 | |
| 284 | if(aNotification) | |
| 285 | 		{
 | |
| 286 | SetSessionFlags(EFsSessionNotifyUser, 0); | |
| 287 | } | |
| 288 | else | |
| 289 | 		{
 | |
| 290 | SetSessionFlags(0, EFsSessionNotifyUser); | |
| 291 | } | |
| 292 | } | |
| 293 | ||
| 294 | // | |
| 295 | // Get iNotifyUser | |
| 296 | // | |
| 297 | TBool CSessionFs::GetNotifyUser() | |
| 298 | 	{
 | |
| 299 | return TestSessionFlags(EFsSessionNotifyUser); | |
| 300 | } | |
| 301 | ||
| 302 | // | |
| 303 | // Notify the user of any read or write failure | |
| 304 | // | |
| 305 | TInt TFsSetNotifyUser::DoRequestL(CFsRequest* aRequest) | |
| 306 | 	{
 | |
| 307 | TBool notification=aRequest->Message().Int0(); | |
| 308 | aRequest->Session()->SetNotifyUser(notification); | |
| 309 | return(KErrNone); | |
| 310 | } | |
| 311 | ||
| 312 | TInt TFsSetNotifyUser::Initialise(CFsRequest* /*aRequest*/) | |
| 313 | 	{
 | |
| 314 | return KErrNone; | |
| 315 | } | |
| 316 | ||
| 317 | ||
| 318 | // | |
| 319 | // Notify the user of any read or write failure | |
| 320 | // | |
| 321 | TInt TFsGetNotifyUser::DoRequestL(CFsRequest* aRequest) | |
| 322 | 	{
 | |
| 323 | TBool notification=aRequest->Session()->GetNotifyUser(); | |
| 324 | TPtrC8 pA((TUint8*)¬ification,sizeof(TBool)); | |
| 325 | aRequest->WriteL(KMsgPtr0,pA); | |
| 326 | return(KErrNone); | |
| 327 | } | |
| 328 | ||
| 329 | TInt TFsGetNotifyUser::Initialise(CFsRequest* /*aRequest*/) | |
| 330 | 	{
 | |
| 331 | return KErrNone; | |
| 332 | } | |
| 333 | ||
| 334 | ||
| 335 | // | |
| 336 | // Get the drive name | |
| 337 | // | |
| 338 | TInt TFsGetDriveName::DoRequestL(CFsRequest* aRequest) | |
| 339 | 	{
 | |
| 340 | TInt driveNum=aRequest->Drive()->DriveNumber(); | |
| 341 | TFileName driveName; | |
| 342 | if (TheDriveNames[driveNum]==NULL) | |
| 343 | driveName.SetLength(0); | |
| 344 | else | |
| 345 | driveName=(*TheDriveNames[driveNum]); | |
| 346 | aRequest->WriteL(KMsgPtr1,driveName); | |
| 347 | return(KErrNone); | |
| 348 | } | |
| 349 | ||
| 350 | ||
| 351 | TInt TFsGetDriveName::Initialise(CFsRequest* aRequest) | |
| 352 | 	{
 | |
| 353 | TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest); | |
| 354 | return(r); | |
| 355 | } | |
| 356 | ||
| 357 | ||
| 358 | ||
| 359 | // | |
| 360 | // Set the drive name | |
| 361 | // | |
| 362 | TInt TFsSetDriveName::DoRequestL(CFsRequest* aRequest) | |
| 363 | 	{
 | |
| 364 | TInt driveNum=aRequest->Drive()->DriveNumber(); | |
| 365 | TFileName driveName; | |
| 366 | aRequest->ReadL(KMsgPtr1,driveName); | |
| 367 | ||
| 368 | // Validate name - return KErrBadName if it contains illegal characters such as | |
| 369 | // * ? / | > < | |
| 370 | ||
| 371 | TNameChecker checker(driveName); | |
| 372 | TText badChar; | |
| 373 | if (checker.IsIllegalName(badChar)) | |
| 374 | return(KErrBadName); | |
| 375 | ||
| 376 | TInt len=((driveName.Length()+31)>>5)<<5; // % 32 | |
| 377 | if (TheDriveNames[driveNum]==NULL) | |
| 378 | TheDriveNames[driveNum]=HBufC::New(len); | |
| 379 | else if (TheDriveNames[driveNum]->Des().MaxLength()<len) | |
| 380 | 		{
 | |
| 381 | HBufC* temp=TheDriveNames[driveNum]->ReAlloc(len); | |
| 382 | if (temp==NULL) | |
| 383 | return(KErrNoMemory); | |
| 384 | TheDriveNames[driveNum]=temp; | |
| 385 | } | |
| 386 | if (TheDriveNames[driveNum]==NULL || TheDriveNames[driveNum]->Des().MaxLength()<len) | |
| 387 | return(KErrNoMemory); | |
| 388 | *TheDriveNames[driveNum]=driveName; | |
| 389 | return(KErrNone); | |
| 390 | } | |
| 391 | ||
| 392 | TInt TFsSetDriveName::Initialise(CFsRequest* aRequest) | |
| 393 | 	{
 | |
| 394 | TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest); | |
| 395 | if (r!=KErrNone) | |
| 396 | return(r); | |
| 397 | 	if (!KCapFsSetDriveName.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Set Drive Name")))
 | |
| 398 | return KErrPermissionDenied; | |
| 399 | return KErrNone; | |
| 400 | } | |
| 401 | ||
| 402 | TInt FlushCachedFiles(CSessionFs* aSession) | |
| 403 | 	{
 | |
| 404 | TInt retVal = KErrNone; | |
| 405 | ||
| 406 | aSession->Handles().Lock(); | |
| 407 | TInt count = aSession->Handles().Count(); | |
| 408 | for (TInt n=0; n<count; n++) | |
| 409 | 		{
 | |
| 410 | CObjPromotion* obj = (CObjPromotion*)aSession->Handles()[n]; | |
| 411 | if (obj != NULL && obj->UniqueID() == FileShares->UniqueID()) | |
| 412 | 			{
 | |
| 413 | CFileShare* share = (CFileShare*) obj; | |
| 414 | if (!share->IsCorrectThread()) | |
| 415 | continue; | |
| 416 | CFileCB& file=((CFileShare*) obj)->File(); | |
| 417 | ||
| 418 | CFileCache* fileCache = file.FileCache(); | |
| 419 | if (fileCache) | |
| 420 | 				{
 | |
| 421 | retVal = fileCache->FlushDirty(); | |
| 422 | if (retVal == CFsRequest::EReqActionBusy) | |
| 423 | break; | |
| 424 | } | |
| 425 | } | |
| 426 | } | |
| 427 | aSession->Handles().Unlock(); | |
| 428 | ||
| 429 | return retVal; | |
| 430 | } | |
| 431 | ||
| 432 | TInt TFsFlushDirtyData::DoRequestL(CFsRequest* aRequest) | |
| 433 | // | |
| 434 | // | |
| 435 | // | |
| 436 | 	{
 | |
| 437 | __CHECK_DRIVETHREAD(aRequest->DriveNumber()); | |
| 438 | ||
| 439 | // Flush all dirty data | |
| 440 | TInt r = FlushCachedFiles(aRequest->Session()); | |
| 441 | if (r == CFsRequest::EReqActionBusy) | |
| 442 | return r; | |
| 443 | return KErrNone; | |
| 444 | } | |
| 445 | ||
| 446 | TInt TFsFlushDirtyData::Initialise(CFsRequest* /*aRequest*/) | |
| 447 | // | |
| 448 | // | |
| 449 | // | |
| 450 | 	{
 | |
| 451 | return(KErrNone); | |
| 452 | } | |
| 453 | ||
| 454 | ||
| 455 | // Iterate though all file shares owned by this session and cancel any async requests | |
| 456 | TInt CancelAsyncRequests(CSessionFs* aSession) | |
| 457 | 	{
 | |
| 458 | TInt retVal = KErrNone; | |
| 459 | ||
| 460 | aSession->Handles().Lock(); | |
| 461 | TInt count = aSession->Handles().Count(); | |
| 462 | for (TInt n=0; n<count; n++) | |
| 463 | 		{
 | |
| 464 | CObjPromotion* obj = (CObjPromotion*)aSession->Handles()[n]; | |
| 465 | if (obj != NULL && obj->UniqueID() == FileShares->UniqueID()) | |
| 466 | 			{
 | |
| 467 | CFileShare* share = (CFileShare*) obj; | |
| 468 | if (!share->IsCorrectThread()) | |
| 469 | continue; | |
| 470 | CFileCB& file=((CFileShare*) obj)->File(); | |
| 471 | file.CancelAsyncReadRequest(share, NULL); | |
| 472 | } | |
| 473 | } | |
| 474 | aSession->Handles().Unlock(); | |
| 475 | ||
| 476 | return retVal; | |
| 477 | } | |
| 478 | ||
| 479 | ||
| 480 | ||
| 481 | TInt TFsCancelSession::DoRequestL(CFsRequest* aRequest) | |
| 482 | 	{
 | |
| 483 | __CHECK_DRIVETHREAD(aRequest->DriveNumber()); | |
| 484 | ||
| 485 | // Cancel any outstanding requests | |
| 486 | CDriveThread* pT=NULL; | |
| 487 | TInt r=FsThreadManager::GetDriveThread(aRequest->DriveNumber(), &pT); | |
| 488 | if(r==KErrNone) | |
| 489 | pT->CompleteSessionRequests(aRequest->Session(),KErrCancel); | |
| 490 | // We must also cancel any ASYNC requests belonging to this session BEFORE | |
| 491 | // ~CSessionFs() is called to avoid a KERN-EXEC 44 (EBadMessageHandle) | |
| 492 | CancelAsyncRequests(aRequest->Session()); | |
| 493 | return(r); | |
| 494 | } | |
| 495 | ||
| 496 | TInt TFsCancelSession::Initialise(CFsRequest* /*aRequest*/) | |
| 497 | 	{
 | |
| 498 | return(KErrNone); | |
| 499 | } | |
| 500 | ||
| 501 | TInt TFsSessionDisconnect::DoRequestL(CFsRequest* aRequest) | |
| 502 | 	{
 | |
| 503 | 	__PRINT(_L("TFsSessionDisconnect::DoRequestL()"));
 | |
| 504 | __ASSERT_DEBUG(FsThreadManager::IsDisconnectThread(),Fault(ESessionDisconnectThread1)); | |
| 505 | CDisconnectThread* pT=FsThreadManager::GetDisconnectThread(); | |
| 506 | ||
| 507 | // Complete requests on all plugins | |
| 508 | CFsInternalRequest* pR=pT->GetRequest(); | |
| 509 | FsPluginManager::CompleteSessionRequests(aRequest->Session(), KErrCancel, pR); | |
| 510 | ||
| 511 | // ...and on all drives | |
| 512 | for(TInt i=0;i<KMaxDrives;++i) | |
| 513 | 		{
 | |
| 514 | FsThreadManager::LockDrive(i); | |
| 515 | if(!FsThreadManager::IsDriveAvailable(i,EFalse)||FsThreadManager::IsDriveSync(i,EFalse)) | |
| 516 | 			{
 | |
| 517 | FsThreadManager::UnlockDrive(i); | |
| 518 | continue; | |
| 519 | } | |
| 520 | pR->Set(CancelSessionOp,aRequest->Session()); | |
| 521 | pR->SetDriveNumber(i); | |
| 522 | pR->Status()=KRequestPending; | |
| 523 | pR->Dispatch(); | |
| 524 | FsThreadManager::UnlockDrive(i); | |
| 525 | User::WaitForRequest(pR->Status()); | |
| 526 | // check request completed or cancelled (by file system dismount which completes requests with KErrNotReady) | |
| 527 | __ASSERT_ALWAYS(pR->Status().Int()==KErrNone||pR->Status().Int()==KErrNotReady,Fault(ESessionDisconnectThread2)); | |
| 528 | 		__THRD_PRINT2(_L("cancel session requests on drive %d r=%d"),i,pR->Status().Int());
 | |
| 529 | ||
| 530 | if (TFileCacheSettings::Flags(i) & (EFileCacheWriteEnabled | EFileCacheWriteOn)) | |
| 531 | 			{
 | |
| 532 | FsThreadManager::LockDrive(i); | |
| 533 | if(!FsThreadManager::IsDriveAvailable(i,EFalse)||FsThreadManager::IsDriveSync(i,EFalse)) | |
| 534 | 				{
 | |
| 535 | FsThreadManager::UnlockDrive(i); | |
| 536 | continue; | |
| 537 | } | |
| 538 | ||
| 539 | // Flush dirty data | |
| 540 | pR->Set(FlushDirtyDataOp,aRequest->Session()); | |
| 541 | pR->SetDriveNumber(i); | |
| 542 | pR->Status()=KRequestPending; | |
| 543 | pR->Dispatch(); | |
| 544 | FsThreadManager::UnlockDrive(i); | |
| 545 | User::WaitForRequest(pR->Status()); | |
| 546 | // check request completed or cancelled (by file system dismount which completes requests with KErrNotReady) | |
| 547 | __ASSERT_ALWAYS(pR->Status().Int()==KErrNone||pR->Status().Int()==KErrNotReady,Fault(ESessionDisconnectThread2)); | |
| 548 | 			__THRD_PRINT2(_L("Flush dirty data on drive %d r=%d"),i,pR->Status().Int());
 | |
| 549 | } | |
| 550 | ||
| 551 | } | |
| 552 | FsNotify::CancelSession(aRequest->Session()); | |
| 553 | ||
| 554 | #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION | |
| 555 | FsNotificationManager::RemoveNotificationRequest(aRequest->Session()); | |
| 556 | #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION | |
| 557 | ||
| 558 | ||
| 559 | // don't delete session here, will be done in CFsDisconnectRequest::Complete() | |
| 560 | return(KErrNone); | |
| 561 | } | |
| 562 | ||
| 563 | TInt TFsSessionDisconnect::Initialise(CFsRequest* /*aRequest*/) | |
| 564 | 	{
 | |
| 565 | return(KErrNone); | |
| 566 | } | |
| 567 | ||
| 568 | TInt TFsCancelPlugin::DoRequestL(CFsRequest* aRequest) | |
| 569 | 	{
 | |
| 570 | //__ASSERT_DEBUG(FsPluginManager::IsPluginThread(),Fault(EFsPluginThreadError)); | |
| 571 | FsPluginManager::CancelPlugin(aRequest->iCurrentPlugin,aRequest->Session()); | |
| 572 | TInt err = aRequest->iCurrentPlugin->SessionDisconnect(aRequest->Session()); | |
| 573 | return(err); | |
| 574 | } | |
| 575 | ||
| 576 | TInt TFsCancelPlugin::Initialise(CFsRequest* /*aRequest*/) | |
| 577 | 	{
 | |
| 578 | // Notify plugin of session disconnect | |
| 579 | return(KErrNone); | |
| 580 | } | |
| 581 | ||
| 582 | TInt TFsSetSessionFlags::DoRequestL(CFsRequest* aRequest) | |
| 583 | 	{
 | |
| 584 | aRequest->Session()->SetSessionFlags(aRequest->Message().Int0(), aRequest->Message().Int1()); | |
| 585 | return(KErrNone); | |
| 586 | } | |
| 587 | ||
| 588 | TInt TFsSetSessionFlags::Initialise(CFsRequest* aRequest) | |
| 589 | 	{
 | |
| 590 | 	if (!KCapFsPlugin. CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Set Session Flags")))
 | |
| 591 | return KErrPermissionDenied; | |
| 592 | return KErrNone; | |
| 593 | } | |
| 594 | ||
| 595 | TInt TFsInitialisePropertiesFile::DoRequestL(CFsRequest* aRequest) | |
| 596 | 	{
 | |
| 597 | 	__PRINT(_L("**TFsInitialisePropertiesFile::DoRequestL**\n"));
 | |
| 598 | TInt err = KErrNone; | |
| 599 | TInt leaveErr = KErrNone; | |
| 600 | const TBool isRomParam = aRequest->Message().Int2(); | |
| 601 | if(isRomParam) | |
| 602 | 		{
 | |
| 603 | const TAny* romAddress = aRequest->Message().Ptr0(); | |
| 604 | TBool isInRom = EFalse; | |
| 605 | TRAP(leaveErr, User::IsRomAddress(isInRom, const_cast<TAny*>(romAddress))); | |
| 606 | if (leaveErr == KErrNone) | |
| 607 | 			{
 | |
| 608 | const TInt length = aRequest->Message().Int1(); | |
| 609 | err = isInRom ? F32Properties::Initialise((TInt)romAddress, length) : KErrNotSupported; | |
| 610 | } | |
| 611 | } | |
| 612 | else | |
| 613 | 		{
 | |
| 614 | err = KErrNotSupported; | |
| 615 | } | |
| 616 | ||
| 617 | #ifdef SYMBIAN_ENABLE_FAT_DIRECTORY_OPT | |
| 618 | // Create the global cache memory manager for FAT dir cache (and other caches). | |
| 619 | // Note: file cache uses its own cache memory manager. | |
| 620 | if (CCacheMemoryManagerFactory::CacheMemoryManager() == NULL) | |
| 621 | 		{
 | |
| 622 | TGlobalCacheMemorySettings::ReadPropertiesFile(); | |
| 623 | TRAPD(r, CCacheMemoryManagerFactory::CreateL()); | |
| 624 | __ASSERT_ALWAYS(r==KErrNone,Fault(ECacheMemoryManagerCreateFailed)); | |
| 625 | } | |
| 626 | #endif // SYMBIAN_ENABLE_FAT_DIRECTORY_OPT | |
| 627 | ||
| 628 | // Create the page cache for file caching etc. | |
| 629 | TGlobalFileCacheSettings::ReadPropertiesFile(); | |
| 630 | if (TGlobalFileCacheSettings::Enabled()) | |
| 631 | 		{
 | |
| 632 | TRAPD(r, CCacheManagerFactory::CreateL()); | |
| 633 | __ASSERT_ALWAYS(r==KErrNone,Fault(EFileCacheCreateFailed)); | |
| 634 | } | |
| 635 | ||
| 636 | User::LeaveIfError(leaveErr); | |
| 637 | return(err); | |
| 638 | } | |
| 639 | ||
| 640 | TInt TFsInitialisePropertiesFile::Initialise(CFsRequest* aRequest) | |
| 641 | 	{
 | |
| 642 | 	if (!KCapDiskAdmin. CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Initialise Property File")))
 | |
| 643 | 		{
 | |
| 644 | return(KErrPermissionDenied); | |
| 645 | } | |
| 646 | ||
| 647 | if (aRequest->Message().SecureId() != KEstartUidValue) | |
| 648 | 		{
 | |
| 649 | return(KErrPermissionDenied); | |
| 650 | } | |
| 651 | ||
| 652 | aRequest->SetDriveNumber(EDriveZ); | |
| 653 | return(KErrNone); | |
| 654 | } |