|
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_svr.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "sf_std.h" |
|
19 #include "sf_cache_man.h" |
|
20 #include "sf_file_cache.h" |
|
21 #include "sf_memory_man.h" |
|
22 |
|
23 TInt DoFsSubClose(CFsRequest* aRequest) |
|
24 // |
|
25 // Close a subsession. |
|
26 // |
|
27 { |
|
28 const TInt handle(aRequest->Message().Int3()); |
|
29 |
|
30 CFsObject* pO=SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
31 if(!pO) |
|
32 return KErrBadHandle; |
|
33 |
|
34 aRequest->Session()->DecResourceCount(); |
|
35 aRequest->Session()->Handles().Remove(handle,ETrue); |
|
36 |
|
37 // this request has also opened this object, so close it here before it |
|
38 // gets to a plugin as a plugin may attempt to open the file/dir itself |
|
39 aRequest->SetScratchValue64( MAKE_TUINT64(I64HIGH(aRequest->ScratchValue64()), 0)); |
|
40 |
|
41 return(KErrNone); |
|
42 } |
|
43 |
|
44 |
|
45 TInt TFsSubClose::DoRequestL(CFsRequest* aRequest) |
|
46 // |
|
47 // Close a subsession. |
|
48 // |
|
49 { |
|
50 |
|
51 // Leave and then panic client with KErrBadHandle if necessary. |
|
52 CFsObject* pO = SessionObjectFromHandle(aRequest->Message().Int3(),0,aRequest->Session()); |
|
53 if(!pO) |
|
54 return KErrBadHandle; |
|
55 |
|
56 if(aRequest->Message().Function() == EFsFileSubClose) |
|
57 { |
|
58 CFileShare* pShare = (CFileShare*) aRequest->ScratchValue(); |
|
59 |
|
60 // flush the file cache |
|
61 CFileCache* fileCache = pShare->File().FileCache(); |
|
62 if (fileCache && fileCache->FlushDirty(aRequest) == CFsRequest::EReqActionBusy) |
|
63 return CFsRequest::EReqActionBusy; |
|
64 |
|
65 // if any write requests are being fair scheduled, wait for them to complete |
|
66 if (pShare->RequestInProgress()) |
|
67 return CFsRequest::EReqActionBusy; |
|
68 } |
|
69 |
|
70 return DoFsSubClose(aRequest); |
|
71 } |
|
72 |
|
73 TInt TFsSubClose::Initialise(CFsRequest* aRequest) |
|
74 // |
|
75 // Now moved to RequestAllocator::GetRequest |
|
76 // |
|
77 { |
|
78 TInt r = KErrNone; |
|
79 // Closing a file share may require flushing of dirty data, so deal with this in the drive thread |
|
80 // in TFsSubClose::DoRequestL(). For other objects (EFsFormatSubClose, EFsDirSubClose, EFsRawSubClose, |
|
81 // FsPluginSubClose) we may complete the message here. |
|
82 if(aRequest->FsFunction() == EFsFileSubClose) |
|
83 { |
|
84 CFileShare* pShare = (CFileShare*) |
|
85 SessionObjectFromHandle(aRequest->Message().Int3(), FileShares->UniqueID(), aRequest->Session()); |
|
86 |
|
87 if(!pShare) |
|
88 User::Leave(KErrBadHandle); |
|
89 |
|
90 HBufC* pFileName = pShare->File().FileName().Alloc(); |
|
91 aRequest->SetScratchValue64( MAKE_TUINT64((TUint) pFileName, (TUint) pShare) ); |
|
92 TInt driveNumber = pShare->File().Drive().DriveNumber(); |
|
93 aRequest->SetDriveNumber(driveNumber); |
|
94 } |
|
95 |
|
96 // Define a completion routine so that we can see whether this request is cancelled - |
|
97 // if it is we still want to close the subsession (but not bother about flushing dirty data) |
|
98 r = ((CFsMessageRequest*) aRequest)->PushOperation(TFsSubClose::Complete); |
|
99 |
|
100 |
|
101 |
|
102 return r; |
|
103 } |
|
104 |
|
105 TInt TFsSubClose::Complete(CFsRequest* aRequest) |
|
106 { |
|
107 // if LastError() != KErrNone, this implies the request has been cancelled. |
|
108 // i.e. TFsSubClose::DoRequestL() has not been called, so we need to call DoFsSubClose() here |
|
109 if (((CFsMessageRequest*) aRequest)->LastError() != KErrNone) |
|
110 DoFsSubClose(aRequest); |
|
111 |
|
112 return CFsRequest::EReqActionComplete; |
|
113 } |
|
114 |
|
115 |
|
116 TInt TFsNotifyChange::DoRequestL(CFsRequest* aRequest) |
|
117 // |
|
118 // |
|
119 // |
|
120 { |
|
121 CStdChangeInfo* notificationInfo=new CStdChangeInfo; |
|
122 if (notificationInfo==NULL) |
|
123 return (KErrNoMemory); |
|
124 const RMessage2& m=aRequest->Message(); |
|
125 notificationInfo->Initialise((TNotifyType)m.Int0(),(TRequestStatus*)m.Ptr1(),m,aRequest->Session()); |
|
126 TInt r=FsNotify::AddChange(notificationInfo,KDriveInvalid); |
|
127 if(r!=KErrNone) |
|
128 delete(notificationInfo); |
|
129 return(r); |
|
130 } |
|
131 |
|
132 |
|
133 TInt TFsNotifyChange::Initialise(CFsRequest* /*aRequest*/) |
|
134 // |
|
135 // |
|
136 // |
|
137 { |
|
138 return(KErrNone); |
|
139 } |
|
140 |
|
141 TInt TFsNotifyChangeEx::DoRequestL(CFsRequest* aRequest) |
|
142 // |
|
143 // Set up an extended change notification |
|
144 // |
|
145 { |
|
146 TUint notifyType=aRequest->Message().Int0(); |
|
147 if (aRequest->Src().NamePresent()) // Monitoring a file |
|
148 { // Reject if iNotifyType is ENotifyDir |
|
149 if (notifyType&ENotifyDir) |
|
150 return (KErrArgument); |
|
151 } |
|
152 CExtChangeInfo* notificationInfo=new CExtChangeInfo; |
|
153 if (notificationInfo==NULL) |
|
154 return (KErrNoMemory); |
|
155 /* TEntry t; |
|
156 TInt ret=aRequest->Drive()->Entry(aRequest->Src().FullName().Mid(2),t); |
|
157 if ((ret==KErrNotFound)||(ret==KErrPathNotFound)||(ret==KErrInUse)) |
|
158 // Path does not yet exist or drive has been locked - still submit request |
|
159 // but mark it as notify all since the client is potentially interested |
|
160 notifyType=ENotifyAll; |
|
161 else if (ret!=KErrNone) |
|
162 { |
|
163 delete notificationInfo; |
|
164 return(ret); |
|
165 }*/ |
|
166 |
|
167 const RMessage2& m=aRequest->Message(); |
|
168 notificationInfo->Initialise((TNotifyType)notifyType,(TRequestStatus*)m.Ptr2(),m,aRequest->Session(),aRequest->Src().FullName().Mid(2)); |
|
169 TInt drive; |
|
170 if (aRequest->ScratchValue()!=0) |
|
171 drive=KDriveInvalid; |
|
172 else |
|
173 drive=aRequest->DriveNumber(); |
|
174 TInt ret=FsNotify::AddChange(notificationInfo,drive); |
|
175 if(ret!=KErrNone) |
|
176 delete(notificationInfo); |
|
177 return(ret); |
|
178 } |
|
179 |
|
180 |
|
181 TInt TFsNotifyChangeEx::Initialise(CFsRequest* aRequest) |
|
182 { |
|
183 // Establish whether the directory or file to watch actually exists |
|
184 // This sets the aSession members iTheName and iTheParse etc |
|
185 TInt ret=KErrNone; |
|
186 TBool monitorAllDrives=EFalse; |
|
187 TFileName notifyPath; |
|
188 |
|
189 TRAP(ret,aRequest->ReadL(KMsgPtr1,notifyPath)); |
|
190 if(ret!=KErrNone) |
|
191 return(ret); |
|
192 if(notifyPath.Length()==0) |
|
193 return(KErrArgument); |
|
194 |
|
195 if ((notifyPath[0]==KMatchAny)||(notifyPath[0]==KMatchOne)) |
|
196 { |
|
197 // Use the default session drive for now |
|
198 // Client has submitted a ? or * for drive |
|
199 monitorAllDrives=ETrue; |
|
200 ret=ParseNotificationPath(aRequest,aRequest->Src(),notifyPath); |
|
201 if (ret!=KErrNone) |
|
202 return(ret); |
|
203 } |
|
204 else |
|
205 { |
|
206 // Client has submitted a single drive to monitor |
|
207 monitorAllDrives=EFalse; |
|
208 |
|
209 ret = ParseNoWildSubstPtr1(aRequest, aRequest->Src()); |
|
210 if (ret!=KErrNone) |
|
211 return(ret); |
|
212 } |
|
213 aRequest->SetScratchValue(monitorAllDrives); |
|
214 ret = PathCheck(aRequest,aRequest->Src().FullName().Mid(2),&KCapFsNotifyChangeEx, __PLATSEC_DIAGNOSTIC_STRING("Extended Change Notifier")); |
|
215 return(ret); |
|
216 } |
|
217 |
|
218 TInt TFsNotifyChangeCancel::DoRequestL(CFsRequest* aRequest) |
|
219 // |
|
220 // |
|
221 // |
|
222 { |
|
223 FsNotify::CancelChangeSession(aRequest->Session()); |
|
224 #if defined(_DEBUG) |
|
225 FsNotify::CancelDebugSession(aRequest->Session()); |
|
226 #endif |
|
227 return(KErrNone); |
|
228 } |
|
229 |
|
230 |
|
231 |
|
232 TInt TFsNotifyChangeCancel::Initialise(CFsRequest* /*aRequest*/) |
|
233 // |
|
234 // |
|
235 // |
|
236 { |
|
237 return KErrNone; |
|
238 } |
|
239 |
|
240 |
|
241 |
|
242 TInt TFsNotifyChangeCancelEx::DoRequestL(CFsRequest* aRequest) |
|
243 // |
|
244 // |
|
245 // |
|
246 { |
|
247 FsNotify::CancelChangeSession(aRequest->Session(),(TRequestStatus*)aRequest->Message().Ptr0()); |
|
248 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
249 FsNotify::CancelDebugSession(aRequest->Session()); |
|
250 #endif |
|
251 return(KErrNone); |
|
252 } |
|
253 |
|
254 |
|
255 |
|
256 TInt TFsNotifyChangeCancelEx::Initialise(CFsRequest* /*aRequest*/) |
|
257 // |
|
258 // |
|
259 // |
|
260 { |
|
261 return KErrNone; |
|
262 } |
|
263 |
|
264 // |
|
265 // Setup a disk space notification request |
|
266 // |
|
267 TInt TFsNotifyDiskSpace::DoRequestL(CFsRequest *aRequest) |
|
268 { |
|
269 //-- first check that the threshold value is correct and is less than the volume size |
|
270 const TUint64 threshold = aRequest->ScratchValue64(); |
|
271 if(threshold <= 0) |
|
272 return KErrArgument; |
|
273 |
|
274 //-- get the size of the mounted volume to check that the requested threshold isn't larger than the volume |
|
275 TUint64 volSz; |
|
276 TInt r = aRequest->Drive()->MountedVolumeSize(volSz); |
|
277 if (r!=KErrNone) |
|
278 return r; |
|
279 |
|
280 if(threshold >= volSz) |
|
281 return KErrArgument; |
|
282 |
|
283 |
|
284 //-- Create the disk space notificator object and append it to the FsNotify queue |
|
285 CDiskSpaceInfo* info=new CDiskSpaceInfo; |
|
286 if(info==NULL) |
|
287 return(KErrNoMemory); |
|
288 |
|
289 const RMessage2& m=aRequest->Message(); |
|
290 info->Initialise((TRequestStatus*)m.Ptr2(),m,aRequest->Session(),threshold); |
|
291 |
|
292 r=FsNotify::AddDiskSpace(info,aRequest->DriveNumber()); |
|
293 if(r!=KErrNone) |
|
294 delete info; |
|
295 |
|
296 return(r); |
|
297 } |
|
298 |
|
299 |
|
300 TInt TFsNotifyDiskSpace::Initialise(CFsRequest *aRequest) |
|
301 // |
|
302 // |
|
303 // |
|
304 { |
|
305 TInt r=ValidateDriveDoSubst(aRequest->Message().Int1(),aRequest); |
|
306 if (r==KErrNone) |
|
307 { |
|
308 TInt64 threshold; |
|
309 TPtr8 tBuf((TUint8*)&threshold,sizeof(TInt64)); |
|
310 aRequest->ReadL(KMsgPtr0,tBuf); |
|
311 aRequest->SetScratchValue64(threshold); |
|
312 } |
|
313 return(r); |
|
314 } |
|
315 |
|
316 TInt TFsNotifyDiskSpaceCancel::DoRequestL(CFsRequest *aRequest) |
|
317 // |
|
318 // Cancel disk space notification |
|
319 // |
|
320 { |
|
321 FsNotify::CancelDiskSpaceSession(aRequest->Session(),(TRequestStatus*)aRequest->Message().Ptr0()); |
|
322 return(KErrNone); |
|
323 } |
|
324 |
|
325 |
|
326 TInt TFsNotifyDiskSpaceCancel::Initialise(CFsRequest* /*aRequest*/) |
|
327 // |
|
328 // |
|
329 // |
|
330 { |
|
331 return(KErrNone); |
|
332 } |
|
333 |
|
334 TInt TFsSynchroniseDriveThread::DoRequestL(CFsRequest* /*aRequest*/) |
|
335 // |
|
336 // This is to ensure that previous message has been handled in drive thread. |
|
337 // |
|
338 { |
|
339 return CFsRequest::EReqActionComplete; |
|
340 } |
|
341 |
|
342 TInt TFsSynchroniseDriveThread::Initialise(CFsRequest *aRequest) |
|
343 // |
|
344 // Set the drive thread. |
|
345 // |
|
346 { |
|
347 if(aRequest->Message().Int0() == -1) //If no drive thread then complete the message |
|
348 { |
|
349 return CFsRequest::EReqActionComplete; |
|
350 } |
|
351 TInt r=ValidateDriveDoSubst(aRequest->Message().Int0(),aRequest); |
|
352 return r; |
|
353 } |
|
354 |
|
355 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
356 EXPORT_C void DebugNotifySessions(TInt aFunction,TInt /*aDrive*/) |
|
357 // |
|
358 // Notify sessions of a debug event |
|
359 // |
|
360 { |
|
361 // Notifying involves memory de-allocation on the file server's heap - |
|
362 // check if we need to switch heaps. |
|
363 RAllocator* current_alloc = &User::Heap(); |
|
364 RAllocator* svr_alloc = ServerThreadAllocator; |
|
365 if (current_alloc != svr_alloc) |
|
366 User::SwitchHeap(svr_alloc); |
|
367 FsNotify::HandleDebug(aFunction); |
|
368 if (current_alloc != svr_alloc) |
|
369 User::SwitchHeap(current_alloc); |
|
370 } |
|
371 #else |
|
372 EXPORT_C void DebugNotifySessions(TInt,TInt) |
|
373 // |
|
374 // Notify sessions of a debug event |
|
375 // |
|
376 {} |
|
377 #endif |
|
378 |
|
379 |
|
380 TInt TFsDriveList::DoRequestL(CFsRequest* aRequest) |
|
381 // |
|
382 // Get the current drive list. |
|
383 // |
|
384 { |
|
385 TDriveList list(KMaxDrives); |
|
386 |
|
387 const TUint mask = (TUint) aRequest->Message().Int1(); |
|
388 const TUint matchedFlags= mask & KDriveAttMatchedFlags; //KDriveAttMatchedFlags = 0xFFF |
|
389 const TUint matchedAtt = mask & KDriveAttMatchedAtt; //KDriveAttMatchedAtt = 0x0FFF0000 |
|
390 |
|
391 TInt r = ValidateMatchMask(mask); |
|
392 if(r!=KErrNone) |
|
393 return r; |
|
394 |
|
395 for (TInt i=0;i<KMaxDrives;i++) |
|
396 { |
|
397 if(RFs::IsValidDrive(i)) |
|
398 { |
|
399 const TUint driveAtt= TheDrives[i].Att(); |
|
400 if(matchedFlags != 0 ) |
|
401 { |
|
402 switch(matchedAtt) |
|
403 { |
|
404 case KDriveAttExclude : |
|
405 { |
|
406 list[i]= (driveAtt & matchedFlags ) ? (TUint8)0:(TUint8)driveAtt ; |
|
407 break; |
|
408 } |
|
409 case 0: |
|
410 { |
|
411 list[i] = (driveAtt & matchedFlags) ? (TUint8)driveAtt:(TUint8)0 ; |
|
412 break; |
|
413 } |
|
414 case KDriveAttExclusive : |
|
415 { |
|
416 if(matchedFlags != KDriveAttLogicallyRemovable) |
|
417 { |
|
418 list[i] = ((TUint8)driveAtt == matchedFlags) ? (TUint8)driveAtt:(TUint8)0; |
|
419 } |
|
420 else |
|
421 { |
|
422 list[i] = (driveAtt == (matchedFlags | KDriveAttRemovable)) ? (TUint8)driveAtt:(TUint8)0; |
|
423 } |
|
424 break; |
|
425 } |
|
426 case KDriveAttExclude | KDriveAttExclusive: |
|
427 { |
|
428 if(matchedFlags != KDriveAttLogicallyRemovable) |
|
429 { |
|
430 list[i] = ((TUint8)driveAtt == matchedFlags) ?(TUint8)0:(TUint8)driveAtt; |
|
431 } |
|
432 else |
|
433 { |
|
434 list[i] = (driveAtt == (matchedFlags | KDriveAttRemovable)) ? (TUint8)driveAtt:(TUint8)0; |
|
435 } |
|
436 break; |
|
437 } |
|
438 default: |
|
439 { |
|
440 return KErrArgument; |
|
441 } |
|
442 } |
|
443 } |
|
444 else //matchedFlags == 0 |
|
445 { |
|
446 switch(matchedAtt) |
|
447 { |
|
448 case 0: |
|
449 list[i] = (TUint8)0 ; |
|
450 break; |
|
451 case KDriveAttAll: |
|
452 list[i]= (TUint8)driveAtt; |
|
453 break; |
|
454 default: //all other cases are incorrect |
|
455 return KErrArgument; |
|
456 } |
|
457 } |
|
458 } |
|
459 else //r!=KErrNone |
|
460 { |
|
461 list[i]=0; |
|
462 } |
|
463 } |
|
464 |
|
465 aRequest->WriteL(KMsgPtr0,list); |
|
466 |
|
467 // Finally, kick off a speculative probe for devices |
|
468 ProxyDrives->Lock(); |
|
469 TInt idx = ProxyDrives->Count(); |
|
470 while(idx--) |
|
471 { |
|
472 CExtProxyDriveFactory* pF = (CExtProxyDriveFactory*)(*ProxyDrives)[idx]; |
|
473 if(pF) |
|
474 { |
|
475 pF->AsyncEnumerate(); |
|
476 } |
|
477 } |
|
478 ProxyDrives->Unlock(); |
|
479 |
|
480 return(KErrNone); |
|
481 } |
|
482 |
|
483 TInt TFsDriveList::Initialise(CFsRequest* /*aRequest*/) |
|
484 // |
|
485 // |
|
486 // |
|
487 { |
|
488 return KErrNone; |
|
489 } |
|
490 |
|
491 TInt TFsDrive::DoRequestL(CFsRequest* aRequest) |
|
492 // |
|
493 // Get drive info. |
|
494 // |
|
495 { |
|
496 // executed in main thread, therefore lock to ensure that |
|
497 // dismount cannot occur during request |
|
498 FsThreadManager::LockDrive(aRequest->DriveNumber()); |
|
499 TDriveInfo info; |
|
500 aRequest->Drive()->DriveInfo(info); |
|
501 if(aRequest->SubstedDrive()) |
|
502 info.iDriveAtt=KDriveAttSubsted; |
|
503 FsThreadManager::UnlockDrive(aRequest->DriveNumber()); |
|
504 TPckgC<TDriveInfo> pInfo(info); |
|
505 aRequest->WriteL(KMsgPtr0,pInfo); |
|
506 return(KErrNone); |
|
507 } |
|
508 |
|
509 TInt TFsDrive::Initialise(CFsRequest* aRequest) |
|
510 // |
|
511 // |
|
512 // |
|
513 { |
|
514 TInt r=ValidateDriveDoSubst(aRequest->Message().Int1(),aRequest); |
|
515 return(r); |
|
516 } |
|
517 |
|
518 |
|
519 /** |
|
520 Get volume info. |
|
521 */ |
|
522 TInt TFsVolume::DoRequestL(CFsRequest* aRequest) |
|
523 { |
|
524 TVolumeInfo v; |
|
525 TPckg<TVolumeInfo> pV(v); |
|
526 |
|
527 //-- read TVolumeInfo from the client side, the client may have provided some data to pass to the server and FSY side |
|
528 aRequest->ReadL(KMsgPtr0,pV); |
|
529 |
|
530 TRequestStatus* pStat = (TRequestStatus*)aRequest->Message().Ptr2(); |
|
531 if(pStat) |
|
532 {//-- the user called an asynchronous version of the RFs::Volume |
|
533 //-- indicate that we request free space asynchronously by setting a special flag that we will pass to the FSY |
|
534 v.iVolSizeAsync = ETrue; |
|
535 //-- at present the user's request will be completed by file server as the result of TFsVolume operation. |
|
536 } |
|
537 else |
|
538 { |
|
539 v.iVolSizeAsync = EFalse; |
|
540 } |
|
541 |
|
542 //-- ask the FSY to provide us its volume information |
|
543 TInt r=aRequest->Drive()->Volume(v); |
|
544 |
|
545 CSessionFs* session=aRequest->Session(); |
|
546 if (r==KErrNone) |
|
547 { |
|
548 TDrive* drive = aRequest->Drive(); |
|
549 const TInt driveNumber = drive->DriveNumber(); |
|
550 |
|
551 if(!session->ReservedAccess(driveNumber)) |
|
552 { |
|
553 const TInt reserve = drive->ReservedSpace(); |
|
554 if(v.iFree <= reserve) |
|
555 v.iFree = 0; |
|
556 else |
|
557 v.iFree -= reserve; |
|
558 } |
|
559 |
|
560 if(aRequest->SubstedDrive()) |
|
561 v.iDrive.iDriveAtt=KDriveAttSubsted; |
|
562 |
|
563 |
|
564 |
|
565 if (drive->IsMounted() && drive->CurrentMount().LocalBufferSupport() == KErrNone && CCacheManagerFactory::CacheManager() != NULL) |
|
566 v.iFileCacheFlags = TFileCacheSettings::Flags(driveNumber); |
|
567 else |
|
568 v.iFileCacheFlags = TFileCacheFlags(0); |
|
569 |
|
570 |
|
571 aRequest->WriteL(KMsgPtr0,pV); |
|
572 } |
|
573 |
|
574 return(r); |
|
575 } |
|
576 |
|
577 TInt TFsVolume::Initialise(CFsRequest* aRequest) |
|
578 // |
|
579 // |
|
580 // |
|
581 { |
|
582 |
|
583 TInt r=ValidateDriveDoSubst(aRequest->Message().Int1(),aRequest); |
|
584 return(r); |
|
585 } |
|
586 |
|
587 |
|
588 TInt TFsSetVolume::DoRequestL(CFsRequest* aRequest) |
|
589 // |
|
590 // Set the volume name. |
|
591 // |
|
592 { |
|
593 TInt r = CheckDiskSpace(0, aRequest); |
|
594 if(r != KErrNone) |
|
595 return r; |
|
596 |
|
597 TFileName volumeName; |
|
598 aRequest->ReadL(KMsgPtr0,volumeName); |
|
599 if (volumeName.Length()>KMaxVolumeNameLength) // KMaxVolumeNameLength = 11 |
|
600 return(KErrBadName); |
|
601 |
|
602 // Validate name - return KErrBadName if it contains illegal characters such as * ? / | > < |
|
603 TNameChecker checker(volumeName); |
|
604 TText badChar; |
|
605 if (checker.IsIllegalName(badChar)) |
|
606 return(KErrBadName); |
|
607 |
|
608 return(aRequest->Drive()->SetVolume(volumeName)); |
|
609 } |
|
610 |
|
611 |
|
612 TInt TFsSetVolume::Initialise(CFsRequest* aRequest) |
|
613 // |
|
614 // |
|
615 // |
|
616 { |
|
617 TInt r=ValidateDriveDoSubst(aRequest->Message().Int1(),aRequest); |
|
618 if (r!=KErrNone) |
|
619 return(r); |
|
620 if (!KCapFsSetVolume.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Set Volume"))) |
|
621 return KErrPermissionDenied; |
|
622 return KErrNone; |
|
623 } |
|
624 |
|
625 |
|
626 TInt TFsSubst::DoRequestL(CFsRequest* aRequest) |
|
627 // |
|
628 // Get a drive substitution. |
|
629 // |
|
630 { |
|
631 TInt r=ValidateDrive(aRequest->Message().Int1(),aRequest); |
|
632 if(r!=KErrNone) |
|
633 return(r); |
|
634 TFileName substName; |
|
635 __PRINT(_L("aRequest->Drive()->Att()&KDriveAttSubsted")); |
|
636 __PRINT1(_L("aRequest->Drive()->Subst()"),&aRequest->Drive()->Subst()); |
|
637 if (aRequest->Drive()->IsSubsted()) |
|
638 substName=aRequest->Drive()->Subst(); |
|
639 aRequest->WriteL(KMsgPtr0,substName); |
|
640 return(KErrNone); |
|
641 } |
|
642 |
|
643 |
|
644 TInt TFsSubst::Initialise(CFsRequest* /*aRequest*/) |
|
645 // |
|
646 // |
|
647 // |
|
648 { |
|
649 return KErrNone; |
|
650 } |
|
651 |
|
652 |
|
653 TInt TFsSetSubst::DoRequestL(CFsRequest* aRequest) |
|
654 // |
|
655 // Set a drive substitution. |
|
656 // |
|
657 { |
|
658 TInt r=ValidateDrive(aRequest->Message().Int1(),aRequest); |
|
659 if (r!=KErrNone) |
|
660 return(r); |
|
661 TDrive* pD=aRequest->Drive(); |
|
662 r=ParsePathPtr0(aRequest,aRequest->Src()); |
|
663 if (r!=KErrNone) |
|
664 return(r); |
|
665 //TODO: no protection for unsubsting drives (could check substed path if system then only CRoot process can unsubst |
|
666 if (pD->IsSubsted() && !aRequest->Src().DrivePresent() && !aRequest->Src().PathPresent()) |
|
667 { |
|
668 delete &pD->Subst(); |
|
669 pD->SetSubst(NULL); |
|
670 pD->SetAtt(0); |
|
671 pD->SetSubstedDrive(NULL); |
|
672 return(KErrNone); |
|
673 } |
|
674 r=PathCheck(aRequest,aRequest->Src().FullName().Mid(2),&KCapFsSysSetSubst,&KCapFsPriSetSubst,&KCapFsROSetSubst, __PLATSEC_DIAGNOSTIC_STRING("Set Subst")); |
|
675 if (r!=KErrNone) |
|
676 return(r); |
|
677 if (pD->Att()&(KDriveAttLocal|KDriveAttRom|KDriveAttRedirected|KDriveAttSubsted)) |
|
678 return(KErrGeneral); |
|
679 if (pD==aRequest->Drive()) |
|
680 return(KErrGeneral); |
|
681 if (aRequest->Drive()->Att()&(KDriveAttRedirected|KDriveAttSubsted)) |
|
682 return(KErrInUse); |
|
683 HBufC* pS=aRequest->Src().FullName().Alloc(); |
|
684 if (pS==NULL) |
|
685 return(KErrNoMemory); |
|
686 __ASSERT_DEBUG(!&pD->SubstedDrive(),Fault(ETFsSetSubstNotNull)); |
|
687 delete &pD->Subst(); |
|
688 pD->SetSubst(pS); |
|
689 pD->SetSubstedDrive(aRequest->Drive()); |
|
690 pD->SetAtt(KDriveAttSubsted); |
|
691 return(KErrNone); |
|
692 } |
|
693 |
|
694 TInt TFsSetSubst::Initialise(CFsRequest* aRequest) |
|
695 // |
|
696 // |
|
697 // |
|
698 { |
|
699 if (!KCapFsSetSubst.CheckPolicy(aRequest->Message(),__PLATSEC_DIAGNOSTIC_STRING("Set subst"))) |
|
700 return KErrPermissionDenied; |
|
701 return KErrNone; |
|
702 } |
|
703 |
|
704 |
|
705 TInt TFsRealName::DoRequestL(CFsRequest* aRequest) |
|
706 // |
|
707 // Get the real name of a file. |
|
708 // |
|
709 { |
|
710 TInt r=ParseSubstPtr0(aRequest,aRequest->Src()); |
|
711 if (r!=KErrNone) |
|
712 return(r); |
|
713 r=PathCheck(aRequest,aRequest->Src().FullName().Mid(2),&KCapFsSysRealName,&KCapFsPriRealName, __PLATSEC_DIAGNOSTIC_STRING("Real Name")); |
|
714 if (r!=KErrNone) |
|
715 return(r); |
|
716 TFileName substName; |
|
717 if (aRequest->Drive()->Att()&KDriveAttRedirected) |
|
718 substName=aRequest->Drive()->Subst(); // DANGER? |
|
719 else |
|
720 substName=aRequest->Src().Drive(); |
|
721 if ((substName.Length()+aRequest->Src().FullName().Mid(2).Length())>KMaxFileName) |
|
722 return(KErrBadName); |
|
723 substName+=aRequest->Src().FullName().Mid(2); |
|
724 aRequest->WriteL(KMsgPtr1,substName); |
|
725 return(KErrNone); |
|
726 } |
|
727 |
|
728 TInt TFsRealName::Initialise(CFsRequest* /*aRequest*/) |
|
729 // |
|
730 // |
|
731 // |
|
732 { |
|
733 return KErrNone; |
|
734 } |
|
735 |
|
736 TInt TFsDefaultPath::DoRequestL(CFsRequest* aRequest) |
|
737 // |
|
738 // Get the default path. |
|
739 // |
|
740 { |
|
741 if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)) |
|
742 return KErrNotSupported; |
|
743 else if(PlatSec::ConfigSetting(PlatSec::EPlatSecDiagnotics)) |
|
744 { |
|
745 //FIXME: to be remove the following when platform is fully secure |
|
746 RThread tT; |
|
747 TInt r=aRequest->Message().Client(tT,EOwnerThread); |
|
748 if(r!=KErrNone) |
|
749 return r; |
|
750 RProcess tP; |
|
751 r=tT.Process(tP); |
|
752 if(r!=KErrNone) |
|
753 { |
|
754 tT.Close(); |
|
755 return r; |
|
756 } |
|
757 TName n; |
|
758 n=tP.Name(); |
|
759 TInt b=n.Locate('['); |
|
760 if (b>=0) |
|
761 n.SetLength(b); |
|
762 RDebug::Print(_L("**** API violation: %S should not use DefaultPath()\n"),&n); |
|
763 tP.Close(); |
|
764 tT.Close(); |
|
765 //FIXME END |
|
766 aRequest->WriteL(KMsgPtr0,TheDefaultPath); |
|
767 return(KErrNone); |
|
768 } |
|
769 else |
|
770 { |
|
771 aRequest->WriteL(KMsgPtr0,TheDefaultPath); |
|
772 return(KErrNone); |
|
773 } |
|
774 } |
|
775 |
|
776 TInt TFsDefaultPath::Initialise(CFsRequest* /*aRequest*/) |
|
777 // |
|
778 // |
|
779 // |
|
780 { |
|
781 return KErrNone; |
|
782 } |
|
783 |
|
784 TInt TFsSetDefaultPath::DoRequestL(CFsRequest* aRequest) |
|
785 // |
|
786 // Set the default path. |
|
787 // |
|
788 { |
|
789 if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)) |
|
790 return KErrNotSupported; |
|
791 else if(PlatSec::ConfigSetting(PlatSec::EPlatSecDiagnotics)) |
|
792 { |
|
793 //FIXME: to be remove the following when platform is fully secure |
|
794 RThread tT; |
|
795 TInt r=aRequest->Message().Client(tT,EOwnerThread); |
|
796 if(r!=KErrNone) |
|
797 return r; |
|
798 RProcess tP; |
|
799 r=tT.Process(tP); |
|
800 if(r!=KErrNone) |
|
801 { |
|
802 tT.Close(); |
|
803 return r; |
|
804 } |
|
805 TName n; |
|
806 n=tP.Name(); |
|
807 TInt b=n.Locate('['); |
|
808 if (b>=0) |
|
809 n.SetLength(b); |
|
810 RDebug::Print(_L("**** API violation: %S should not use SetDefaultPath()\n"),&n); |
|
811 tP.Close(); |
|
812 tT.Close(); |
|
813 //FIXME END |
|
814 TParse parse; |
|
815 /*TInt*/ r=ParsePathPtr0(aRequest,parse); |
|
816 if (r!=KErrNone && r!=KErrInUse) |
|
817 return(r); |
|
818 if (IsIllegalFullName(parse.FullName())) |
|
819 return(KErrBadName); |
|
820 TheDefaultPath=parse.FullName(); |
|
821 return(KErrNone); |
|
822 } |
|
823 else |
|
824 { |
|
825 TParse parse; |
|
826 TInt r=ParsePathPtr0(aRequest,parse); |
|
827 if (r!=KErrNone && r!=KErrInUse) |
|
828 return(r); |
|
829 if (IsIllegalFullName(parse.FullName())) |
|
830 return(KErrBadName); |
|
831 TheDefaultPath=parse.FullName(); |
|
832 return(KErrNone); |
|
833 } |
|
834 } |
|
835 |
|
836 |
|
837 TInt TFsSetDefaultPath::Initialise(CFsRequest* /*aRequest*/) |
|
838 // |
|
839 // |
|
840 // |
|
841 { |
|
842 return KErrNone; |
|
843 } |
|
844 |
|
845 TInt TFsSessionPath::DoRequestL(CFsRequest* aRequest) |
|
846 // |
|
847 // Get the session path |
|
848 // |
|
849 { |
|
850 aRequest->WriteL(KMsgPtr0,aRequest->Session()->Path()); |
|
851 return(KErrNone); |
|
852 } |
|
853 |
|
854 TInt TFsSessionPath::Initialise(CFsRequest* /*aRequest*/) |
|
855 // |
|
856 // |
|
857 // |
|
858 { |
|
859 return KErrNone; |
|
860 } |
|
861 |
|
862 |
|
863 TInt TFsSetSessionPath::DoRequestL(CFsRequest* aRequest) |
|
864 // |
|
865 // Set the session path |
|
866 // |
|
867 { |
|
868 TParse parse; |
|
869 TInt r=ParsePathPtr0(aRequest,parse); |
|
870 if (r!=KErrNone && r!=KErrInUse) |
|
871 return(r); |
|
872 r=PathCheck(aRequest,parse.FullName().Mid(2),&KCapFsSysSetSessionPath,&KCapFsPriSetSessionPath, __PLATSEC_DIAGNOSTIC_STRING("Set Session Path")); |
|
873 if (r!=KErrNone) |
|
874 return(r); |
|
875 if (IsIllegalFullName(parse.FullName())) |
|
876 return(KErrBadName); |
|
877 HBufC* pP=parse.FullName().Alloc(); |
|
878 if (pP==NULL) |
|
879 return(KErrNoMemory); |
|
880 delete &aRequest->Session()->Path(); |
|
881 aRequest->Session()->SetPath(pP); |
|
882 return(KErrNone); |
|
883 } |
|
884 |
|
885 TInt TFsSetSessionPath::Initialise(CFsRequest* /*aRequest*/) |
|
886 // |
|
887 // |
|
888 // |
|
889 { |
|
890 return(KErrNone); |
|
891 } |
|
892 |
|
893 |
|
894 TInt TFsParse::DoRequestL(CFsRequest* aRequest) |
|
895 // |
|
896 // Parse a file name. |
|
897 // |
|
898 { |
|
899 TFileName name; |
|
900 aRequest->ReadL(KMsgPtr0,name); |
|
901 TFileName rel; |
|
902 if (aRequest->Message().Ptr1()!=NULL) |
|
903 aRequest->ReadL(KMsgPtr1,rel); |
|
904 TParse p; |
|
905 TInt r=p.Set(name,&rel,&aRequest->Session()->Path()); |
|
906 if (r==KErrNone) |
|
907 { |
|
908 TPckgC<TParse> pP(p); |
|
909 aRequest->WriteL(KMsgPtr2,pP); |
|
910 } |
|
911 return(r); |
|
912 } |
|
913 |
|
914 TInt TFsParse::Initialise(CFsRequest* /*aRequest*/) |
|
915 // |
|
916 // |
|
917 // |
|
918 { |
|
919 return KErrNone; |
|
920 } |
|
921 |
|
922 TInt TFsReserveDriveSpace::DoRequestL(CFsRequest* aRequest) |
|
923 // |
|
924 // set reserved value to add to a drives reserved area |
|
925 // |
|
926 { |
|
927 // extract request info |
|
928 CSessionFs* session=aRequest->Session(); |
|
929 TDrive* drive = aRequest->Drive(); |
|
930 |
|
931 if(session->ReservedAccess(drive->DriveNumber())) |
|
932 return KErrInUse; |
|
933 |
|
934 const TInt reserve = aRequest->Message().Int1(); //-- bytes to reserve on the drive |
|
935 |
|
936 // Check if requested reserve space is within the range |
|
937 if(reserve > KMaxSessionDriveReserved || reserve < 0) |
|
938 return KErrArgument; |
|
939 |
|
940 const TInt64 threshold = reserve + drive->ReservedSpace(); //-- free bytes on the volume we actually need |
|
941 |
|
942 TInt nRes = drive->RequestFreeSpaceOnMount(threshold); |
|
943 if(nRes != KErrNone) |
|
944 return nRes; |
|
945 |
|
946 const TInt current = session->Reserved(drive->DriveNumber()); |
|
947 const TInt diff = reserve - current; |
|
948 TInt drvReserved = drive->ReservedSpace(); |
|
949 if((drvReserved + diff) > KMaxTotalDriveReserved) |
|
950 return KErrTooBig; |
|
951 |
|
952 drvReserved += diff; |
|
953 drive->SetReservedSpace(drvReserved); |
|
954 return session->SetReserved(drive->DriveNumber(), reserve); |
|
955 |
|
956 } |
|
957 |
|
958 TInt TFsReserveDriveSpace::Initialise(CFsRequest* aRequest) |
|
959 // |
|
960 // Validate drive and set up the session parameters for request |
|
961 // |
|
962 { |
|
963 // if (!KCapFsReserveDriveSpace.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Reserve Drive Space"))) |
|
964 // return KErrPermissionDenied; |
|
965 TInt drvNumber=aRequest->Message().Int1(); |
|
966 drvNumber=aRequest->Message().Int0(); |
|
967 TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest); |
|
968 return(r); |
|
969 } |
|
970 |
|
971 |
|
972 TInt TFsGetReserveAccess::DoRequestL(CFsRequest* aRequest) |
|
973 // |
|
974 // Get reserved access to a drives reserved area first checking that the session has first reserved some space |
|
975 // |
|
976 { |
|
977 CSessionFs* session=aRequest->Session(); |
|
978 |
|
979 TInt size=session->Reserved(aRequest->Drive()->DriveNumber()); |
|
980 if(size <= 0) |
|
981 return KErrPermissionDenied; |
|
982 else |
|
983 session->SetReservedAccess(aRequest->Drive()->DriveNumber(),ETrue); |
|
984 return KErrNone; |
|
985 } |
|
986 |
|
987 TInt TFsGetReserveAccess::Initialise(CFsRequest* aRequest) |
|
988 // |
|
989 // |
|
990 // |
|
991 { |
|
992 // if (!KCapFsGetReserveAccess.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Get Reserve Access"))) |
|
993 // return KErrPermissionDenied; |
|
994 TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest); |
|
995 return(r); |
|
996 } |
|
997 |
|
998 |
|
999 TInt TFsReleaseReserveAccess::DoRequestL(CFsRequest* aRequest) |
|
1000 // |
|
1001 // Remove access for this session to the locked area for a given drive |
|
1002 // |
|
1003 { |
|
1004 aRequest->Session()->SetReservedAccess(aRequest->Drive()->DriveNumber(),EFalse); |
|
1005 return KErrNone; |
|
1006 } |
|
1007 |
|
1008 TInt TFsReleaseReserveAccess::Initialise(CFsRequest* aRequest) |
|
1009 // |
|
1010 // |
|
1011 // |
|
1012 { |
|
1013 // if (!KCapFsReleaseReserveAccess.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Release Reserve Access"))) |
|
1014 // return KErrPermissionDenied; |
|
1015 TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest); |
|
1016 return(r); |
|
1017 } |
|
1018 |
|
1019 TInt TFsSetStartupConfiguration::DoRequestL(CFsRequest* aRequest) |
|
1020 // |
|
1021 // Configure file server according to command and parameters. |
|
1022 // |
|
1023 { |
|
1024 TInt cmd = aRequest->Message().Int0(); |
|
1025 |
|
1026 switch (cmd) |
|
1027 { |
|
1028 case ELoaderPriority: |
|
1029 // Set loader thread priority |
|
1030 { |
|
1031 TInt r; |
|
1032 TFullName loaderFullName(RProcess().FullName()); |
|
1033 loaderFullName.Append(_L("::LoaderThread")); |
|
1034 RThread loader; |
|
1035 r = loader.Open(loaderFullName); |
|
1036 if (r != KErrNone) |
|
1037 return r; |
|
1038 loader.SetPriority((TThreadPriority)aRequest->Message().Int1()); |
|
1039 loader.Close(); |
|
1040 } |
|
1041 break; |
|
1042 case ESetRugged: |
|
1043 { |
|
1044 TInt drive = aRequest->Message().Int1(); |
|
1045 TInt r = ValidateDrive(drive, aRequest); |
|
1046 if (r != KErrNone) |
|
1047 return r; |
|
1048 TInt value = aRequest->Message().Int2(); |
|
1049 aRequest->Drive()->SetRugged(value); |
|
1050 } |
|
1051 break; |
|
1052 default: |
|
1053 return KErrArgument; |
|
1054 } |
|
1055 |
|
1056 return KErrNone; |
|
1057 } |
|
1058 |
|
1059 TInt TFsSetStartupConfiguration::Initialise(CFsRequest* aRequest) |
|
1060 // |
|
1061 // Check SID of message sender. Can be estart only |
|
1062 // |
|
1063 { |
|
1064 if (aRequest->Message().SecureId() != KEstartUidValue) |
|
1065 return KErrPermissionDenied; |
|
1066 return KErrNone; |
|
1067 } |
|
1068 |
|
1069 |
|
1070 const TInt KinitialChanges = EChangesLocale|EChangesMidnightCrossover|EChangesThreadDeath|EChangesPowerStatus|EChangesSystemTime|EChangesFreeMemory|EChangesOutOfMemory; |
|
1071 |
|
1072 CKernEventNotifier* CKernEventNotifier::New(TInt aPriority) |
|
1073 { |
|
1074 __PRINT(_L("CKernEventNotifier::New")); |
|
1075 CKernEventNotifier* self = new CKernEventNotifier(aPriority); |
|
1076 if (self && (self->iChangeNotifier.Create() != KErrNone)) |
|
1077 delete self, self = NULL; |
|
1078 return self; |
|
1079 } |
|
1080 |
|
1081 CKernEventNotifier::~CKernEventNotifier() |
|
1082 { |
|
1083 Cancel(); |
|
1084 iChangeNotifier.Close(); |
|
1085 } |
|
1086 |
|
1087 void CKernEventNotifier::Start() |
|
1088 { |
|
1089 SetActive(); |
|
1090 iChangeNotifier.Logon(iStatus); |
|
1091 } |
|
1092 |
|
1093 void CKernEventNotifier::RunL() |
|
1094 { |
|
1095 __PRINT(_L("CKernEventNotifier::RunL")); |
|
1096 iChange = iStatus.Int(); |
|
1097 Start(); |
|
1098 |
|
1099 /* Avoid being triggered by initial events */ |
|
1100 if (iChange != 0 && (iChange & KinitialChanges) != KinitialChanges) |
|
1101 { |
|
1102 if (iChange & EChangesLocale) |
|
1103 CKernEventNotifier::LocaleChangeCallback(); |
|
1104 if (iChange & EChangesFreeMemory) |
|
1105 CKernEventNotifier::FreeMemoryChangeCallback(); |
|
1106 // Add other event capture below this line |
|
1107 iChange = 0; |
|
1108 } |
|
1109 } |
|
1110 |
|
1111 void CKernEventNotifier::DoCancel() |
|
1112 { |
|
1113 iChangeNotifier.LogonCancel(); |
|
1114 } |
|
1115 |
|
1116 |
|
1117 extern TBool FatUtilitiesUpdateDrivesNotified; |
|
1118 extern TBool FatUtilityFunctionsSet; |
|
1119 |
|
1120 TInt CKernEventNotifier::LocaleChangeCallback(TAny*) |
|
1121 { |
|
1122 __PRINT(_L("CKernEventNotifier::LocaleChangeCallback")); |
|
1123 |
|
1124 //-- check if the locale has just been set and the drives are not yet notified about this. |
|
1125 if(FatUtilityFunctionsSet && !FatUtilitiesUpdateDrivesNotified) |
|
1126 {//-- notify drives about locale shange, but only once |
|
1127 for(TInt i=0; i<KMaxDrives; i++) |
|
1128 { |
|
1129 TDrive& drive=TheDrives[i]; |
|
1130 |
|
1131 if(drive.DriveNumber() >=0 && drive.IsRemovable() && !drive.IsSubsted()) |
|
1132 { |
|
1133 __PRINT1(_L("CKernEventNotifier::LocaleChangeCallback upd drive: %d"), drive.DriveNumber()); |
|
1134 drive.SetChanged(ETrue); |
|
1135 } |
|
1136 } |
|
1137 |
|
1138 FatUtilitiesUpdateDrivesNotified = ETrue; |
|
1139 } |
|
1140 |
|
1141 return KErrNone; |
|
1142 } |
|
1143 |
|
1144 TInt TFsQueryVolumeInfoExt::DoRequestL(CFsRequest* aRequest) |
|
1145 { |
|
1146 const TInt cmd = aRequest->Message().Int1(); |
|
1147 TInt rel; |
|
1148 |
|
1149 TDrive* pDrive = aRequest->Drive(); |
|
1150 |
|
1151 rel = pDrive->CheckMount(); |
|
1152 if(rel != KErrNone) |
|
1153 return rel; |
|
1154 |
|
1155 switch (cmd) |
|
1156 { |
|
1157 |
|
1158 //------------------------------------------------- |
|
1159 //-- file system sub type query |
|
1160 case EFileSystemSubType: |
|
1161 { |
|
1162 TFSName name; |
|
1163 if (pDrive->IsMounted()) |
|
1164 { |
|
1165 rel = pDrive->CurrentMount().FileSystemSubType(name); |
|
1166 |
|
1167 //-- get the Mount's file system name if the FS subtype query is not supported or there are no subtypes. |
|
1168 if (rel==KErrNotSupported) |
|
1169 { |
|
1170 pDrive->CurrentMount().FileSystemName(name); |
|
1171 } |
|
1172 |
|
1173 if (name.Length()) |
|
1174 { |
|
1175 TPckgBuf<TFSName> pckgBuf(name); |
|
1176 aRequest->WriteL(KMsgPtr2, pckgBuf); |
|
1177 return KErrNone; |
|
1178 } |
|
1179 else |
|
1180 { |
|
1181 return rel; |
|
1182 } |
|
1183 } |
|
1184 else |
|
1185 { |
|
1186 return KErrNotReady; |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 |
|
1191 //------------------------------------------------- |
|
1192 //-- this is RFs::VolumeIOParam() query |
|
1193 case EIOParamInfo: |
|
1194 { |
|
1195 TVolumeIOParamInfo ioInfo; |
|
1196 // 1. gets block size information via media driver |
|
1197 const TInt drive = aRequest->Message().Int0(); |
|
1198 |
|
1199 // validates local drive numbers |
|
1200 if(!IsValidLocalDriveMapping(drive)) |
|
1201 { |
|
1202 ioInfo.iBlockSize = KErrNotReady; |
|
1203 } |
|
1204 else |
|
1205 { |
|
1206 // Get media capability |
|
1207 TLocalDriveCapsV6Buf capsBuf; |
|
1208 |
|
1209 // is the drive local? |
|
1210 if (!IsProxyDrive(drive)) |
|
1211 { |
|
1212 // if not valid local drive, use default values in localDriveCaps |
|
1213 // if valid local drive and not locked, use TBusLocalDrive::Caps() values |
|
1214 // if valid drive and locked, hard-code attributes |
|
1215 rel = GetLocalDrive(drive).Caps(capsBuf); |
|
1216 } |
|
1217 else // this need to be made a bit nicer |
|
1218 { |
|
1219 CExtProxyDrive* pD = GetProxyDrive(drive); |
|
1220 if(pD) |
|
1221 rel = pD->Caps(capsBuf); |
|
1222 else |
|
1223 rel = KErrNotReady; |
|
1224 } |
|
1225 |
|
1226 if (rel != KErrNone) |
|
1227 { |
|
1228 ioInfo.iBlockSize = rel; |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 TLocalDriveCapsV6& caps = capsBuf(); |
|
1233 if (caps.iBlockSize) |
|
1234 { |
|
1235 ioInfo.iBlockSize = caps.iBlockSize; |
|
1236 } |
|
1237 // returns default size (512) when block is not supported by |
|
1238 // underlying media |
|
1239 else |
|
1240 { |
|
1241 ioInfo.iBlockSize = KDefaultVolumeBlockSize; |
|
1242 } |
|
1243 } |
|
1244 } |
|
1245 |
|
1246 // 2. gets cluster size via mounted file system; Also get Max. file size supported by the file system |
|
1247 |
|
1248 ioInfo.iMaxSupportedFileSize = KMaxTUint64; //-- the value for "not supported case" |
|
1249 |
|
1250 if (pDrive->IsMounted()) |
|
1251 { |
|
1252 rel = pDrive->CurrentMount().FileSystemClusterSize(); |
|
1253 ioInfo.iClusterSize = rel; // return cluster size or an error code if error happened. |
|
1254 |
|
1255 pDrive->CurrentMount().GetMaxSupportedFileSize(ioInfo.iMaxSupportedFileSize); |
|
1256 |
|
1257 } |
|
1258 else |
|
1259 { |
|
1260 ioInfo.iClusterSize = KErrNotReady; |
|
1261 } |
|
1262 |
|
1263 // 3. get rec buffer size from estart.txt file |
|
1264 { |
|
1265 _LIT8(KLitSectionNameDrive,"Drive%C"); |
|
1266 ioInfo.iRecReadBufSize = KErrNotSupported; |
|
1267 ioInfo.iRecWriteBufSize = KErrNotSupported; |
|
1268 |
|
1269 TBuf8<8> sectionName; |
|
1270 TInt32 bufSize; |
|
1271 sectionName.Format(KLitSectionNameDrive, 'A' + drive); |
|
1272 // retrieve recommended buffer size information through F32 INI section |
|
1273 if (F32Properties::GetInt(sectionName, _L8("RecReadBufSize"), bufSize)) |
|
1274 { |
|
1275 ioInfo.iRecReadBufSize = bufSize; |
|
1276 } |
|
1277 if (F32Properties::GetInt(sectionName, _L8("RecWriteBufSize"), bufSize)) |
|
1278 { |
|
1279 ioInfo.iRecWriteBufSize = bufSize; |
|
1280 } |
|
1281 |
|
1282 // packaging and returning results |
|
1283 TPckgBuf<TVolumeIOParamInfo> pckgBuf(ioInfo); |
|
1284 aRequest->WriteL(KMsgPtr2, pckgBuf); |
|
1285 } |
|
1286 |
|
1287 // always return KErrNone as error codes are packaged and returned via ioInfo members |
|
1288 return KErrNone; |
|
1289 } //case EIOParamInfo: |
|
1290 |
|
1291 //------------------------------------------------- |
|
1292 //-- check if the specified drive is synchronous or not |
|
1293 case EIsDriveSync: |
|
1294 { |
|
1295 const TInt drive = aRequest->Message().Int0(); |
|
1296 const TBool bDrvSynch = FsThreadManager::IsDriveSync(drive, EFalse); |
|
1297 TPckgBuf<TBool> buf(bDrvSynch); |
|
1298 aRequest->WriteL(KMsgPtr2, buf); |
|
1299 |
|
1300 return KErrNone; |
|
1301 } |
|
1302 |
|
1303 //------------------------------------------------- |
|
1304 //-- query if the drive is finalised |
|
1305 case EIsDriveFinalised: |
|
1306 { |
|
1307 TBool bFinalised; |
|
1308 TInt nRes = pDrive->CurrentMount().IsMountFinalised(bFinalised); |
|
1309 if(nRes != KErrNone) |
|
1310 return nRes; |
|
1311 |
|
1312 TPckgBuf<TBool> buf(bFinalised); |
|
1313 aRequest->WriteL(KMsgPtr2, buf); |
|
1314 |
|
1315 return KErrNone; |
|
1316 } |
|
1317 |
|
1318 |
|
1319 default: |
|
1320 { |
|
1321 return KErrNotSupported; |
|
1322 } |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 TInt TFsQueryVolumeInfoExt::Initialise(CFsRequest* aRequest) |
|
1327 { |
|
1328 TInt r = ValidateDriveDoSubst(aRequest->Message().Int0(),aRequest); |
|
1329 return r; |
|
1330 } |
|
1331 |
|
1332 TInt CKernEventNotifier::FreeMemoryChangeCallback() |
|
1333 { |
|
1334 __PRINT(_L("CKernEventNotifier::FreeMemoryChangeCallback")); |
|
1335 |
|
1336 TBool belowThreshold = (iChange & EChangesLowMemory)?(TBool)ETrue:(TBool)EFalse; |
|
1337 CCacheManager* manager = CCacheManagerFactory::CacheManager(); |
|
1338 if (manager) |
|
1339 { |
|
1340 manager->FreeMemoryChanged(belowThreshold); |
|
1341 |
|
1342 // start flushing all dirty data |
|
1343 if (belowThreshold) |
|
1344 { |
|
1345 Files->Lock(); |
|
1346 TInt count=Files->Count(); |
|
1347 while(count--) |
|
1348 { |
|
1349 CFileCB* file = (CFileCB*)(*Files)[count]; |
|
1350 if (file->FileCache()) |
|
1351 // Cannot report errors here |
|
1352 // coverity [unchecked_value] |
|
1353 (void)file->FileCache()->FlushDirty(); |
|
1354 } |
|
1355 Files->Unlock(); |
|
1356 } |
|
1357 } |
|
1358 |
|
1359 #ifdef SYMBIAN_ENABLE_FAT_DIRECTORY_OPT |
|
1360 CCacheMemoryManager* cacheMemManager = CCacheMemoryManagerFactory::CacheMemoryManager(); |
|
1361 if (cacheMemManager) |
|
1362 cacheMemManager->FreeMemoryChanged(belowThreshold); |
|
1363 #endif //#ifdef SYMBIAN_ENABLE_FAT_DIRECTORY_OPT |
|
1364 |
|
1365 return KErrNone; |
|
1366 } |
|
1367 |