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