10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // CMassStorageFileSystem implementation. |
14 // CMassStorageFileSystem implementation. |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
20 @internalTechnology |
20 @internalTechnology |
21 */ |
21 */ |
22 |
22 |
23 #include <f32file.h> |
23 #include <f32file.h> |
24 #include <f32ver.h> |
24 #include <f32ver.h> |
|
25 #include "drivemanager.h" |
25 #include "cusbmassstoragecontroller.h" |
26 #include "cusbmassstoragecontroller.h" |
26 #include "cmassstoragefilesystem.h" |
27 #include "cmassstoragefilesystem.h" |
27 #include "cmassstoragemountcb.h" |
28 #include "cmassstoragemountcb.h" |
28 #include "massstoragedebug.h" |
|
29 #include "massstorage.h" |
29 #include "massstorage.h" |
|
30 |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "cmassstoragefilesystemTraces.h" |
|
34 #endif |
|
35 |
30 |
36 |
31 _LIT(KMsFsyName, "MassStorageFileSystem"); |
37 _LIT(KMsFsyName, "MassStorageFileSystem"); |
32 _LIT(KMsThreadName, "MassStorageThread"); |
38 _LIT(KMsThreadName, "MassStorageThread"); |
33 _LIT(KMsDeadThreadName, "MassStorageDeadThread"); |
39 _LIT(KMsDeadThreadName, "MassStorageDeadThread"); |
34 _LIT(KMsFsysSemName, "MassStorageSemaphore"); |
40 _LIT(KMsFsysSemName, "MassStorageSemaphore"); |
35 LOCAL_D const TInt KMsFsyMajorVersionNumber=1; |
41 static const TInt KMsFsyMajorVersionNumber=1; |
36 LOCAL_D const TInt KMsFsyMinorVersionNumber=0; |
42 static const TInt KMsFsyMinorVersionNumber=0; |
37 |
43 |
38 CMassStorageFileSystem::CMassStorageFileSystem() |
44 CMassStorageFileSystem::CMassStorageFileSystem() |
39 { |
45 { |
40 } |
46 } |
41 |
47 |
42 CMassStorageFileSystem::~CMassStorageFileSystem() |
48 CMassStorageFileSystem::~CMassStorageFileSystem() |
43 { |
49 { |
44 //Kill the controller thread if it exists |
50 //Kill the controller thread if it exists |
45 delete iMassStorageController; |
51 delete iMassStorageController; |
46 delete iMediaChanged; |
52 delete iMediaChanged; |
47 RThread thread; |
53 RThread thread; |
48 TInt err = thread.Open(KMsThreadName); |
54 TInt err = thread.Open(KMsThreadName); |
49 if (err == KErrNone) |
55 if (err == KErrNone) |
50 { |
56 { |
51 thread.Kill(1); //Parameter is irrelevant |
57 thread.Kill(1); //Parameter is irrelevant |
52 } |
58 } |
53 thread.Close(); |
59 thread.Close(); |
54 iMsDrives.Close(); |
60 iMsDrives.Close(); |
55 } |
61 } |
56 |
62 |
57 CMassStorageFileSystem* CMassStorageFileSystem::NewL() |
63 CMassStorageFileSystem* CMassStorageFileSystem::NewL() |
58 { |
64 { |
59 CMassStorageFileSystem* self = new (ELeave) CMassStorageFileSystem(); |
65 CMassStorageFileSystem* self = new (ELeave) CMassStorageFileSystem(); |
60 CleanupStack::PushL(self); |
66 CleanupStack::PushL(self); |
61 self->ConstructL(); |
67 self->ConstructL(); |
62 CleanupStack::Pop(self); |
68 CleanupStack::Pop(self); |
63 return self; |
69 return self; |
64 } |
70 } |
65 |
71 |
66 void CMassStorageFileSystem::ConstructL() |
72 void CMassStorageFileSystem::ConstructL() |
67 { |
73 { |
68 iMediaChanged = new(ELeave) CArrayFixFlat<TBool>(KMaxDrives); |
74 iMediaChanged = new(ELeave) CArrayFixFlat<TBool>(KMaxDrives); |
69 } |
75 } |
70 |
76 |
71 /** |
77 /** |
72 Set the file system version and name |
78 Set the file system version and name |
73 |
79 |
74 @return Any of the standard Symbian error codes. |
80 @return Any of the standard Symbian error codes. |
75 */ |
81 */ |
76 TInt CMassStorageFileSystem::Install() |
82 TInt CMassStorageFileSystem::Install() |
77 { |
83 { |
78 __PRINT(_L("CMassStorageFileSystem::Install In\n")); |
84 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_100); |
79 iVersion=TVersion(KMsFsyMajorVersionNumber, KMsFsyMinorVersionNumber, KF32BuildVersionNumber); |
85 iVersion=TVersion(KMsFsyMajorVersionNumber, KMsFsyMinorVersionNumber, KF32BuildVersionNumber); |
80 TInt err = SetName(&KMsFsyName); |
86 TInt err = SetName(&KMsFsyName); |
81 __PRINT(_L("CMassStorageFileSystem::Install Out\n")); |
87 return err; |
82 return err; |
88 } |
83 } |
|
84 |
89 |
85 TInt CMassStorageFileSystem::Remove() |
90 TInt CMassStorageFileSystem::Remove() |
86 { |
91 { |
87 __PRINT(_L("CMassStorageFileSystem::Remove In\n")); |
92 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_101); |
88 TInt err = KErrNone; |
93 TInt err = KErrNone; |
89 if (iInstalled) |
94 if (iInstalled) |
90 { |
95 { |
91 // Try connecting to the server to send a shutdown message. |
96 // Try connecting to the server to send a shutdown message. |
92 // - If the class controller has a session in use, this will return KErrInUse |
97 // - If the class controller has a session in use, this will return KErrInUse |
93 RUsbMassStorage usbMs; |
98 RUsbMassStorage usbMs; |
94 err = usbMs.Connect(); |
99 err = usbMs.Connect(); |
95 if(err == KErrNone) |
100 if(err == KErrNone) |
96 { |
101 { |
97 err = usbMs.Shutdown(); |
102 err = usbMs.Shutdown(); |
98 usbMs.Close(); |
103 usbMs.Close(); |
99 |
104 |
100 if(err == KErrNone) |
105 if(err == KErrNone) |
101 { |
106 { |
102 User::WaitForRequest(iThreadStat); |
107 User::WaitForRequest(iThreadStat); |
103 err = iThreadStat.Int(); |
108 err = iThreadStat.Int(); |
104 } |
109 } |
105 else |
110 else |
106 { |
111 { |
107 __PRINT1(_L("CMassStorageFileSystem::Remove Shutdown Error %d\n"),err); |
112 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_102, |
108 } |
113 "Shutdown Error %d", err); |
109 } |
114 } |
110 else |
115 } |
111 { |
116 else |
112 __PRINT1(_L("CMassStorageFileSystem::Remove Connect Error %d\n"),err); |
117 { |
113 } |
118 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_103, |
114 } |
119 "Connect Error %d", err); |
115 __PRINT(_L("CMassStorageFileSystem::Remove Out\n")); |
120 } |
116 return(err); |
121 } |
117 } |
122 return(err); |
|
123 } |
118 |
124 |
119 /** |
125 /** |
120 Creates a new Mass Storage mount object. |
126 Creates a new Mass Storage mount object. |
121 |
127 |
122 @return A new CMassStorageMountCB |
128 @return A new CMassStorageMountCB |
123 @leave KErrNotReady if the Mass Storage controller is not running. |
129 @leave KErrNotReady if the Mass Storage controller is not running. |
124 */ |
130 */ |
125 CMountCB* CMassStorageFileSystem::NewMountL() const |
131 CMountCB* CMassStorageFileSystem::NewMountL() const |
126 { |
132 { |
127 if (!iRunning) |
133 if (!iRunning) |
128 { |
134 { |
129 User::Leave(KErrNotReady); |
135 User::Leave(KErrNotReady); |
130 } |
136 } |
131 return CMassStorageMountCB::NewL(iMsDrives); |
137 return CMassStorageMountCB::NewL(iMsDrives); |
132 } |
138 } |
133 |
139 |
134 /** |
140 /** |
135 Sets the media attributes and type in the aInfo parameter to those of the specified drive. |
141 Sets the media attributes and type in the aInfo parameter to those of the specified drive. |
136 |
142 |
137 @param anInfo TDriveInfo object to store the drive information. |
143 @param anInfo TDriveInfo object to store the drive information. |
138 @param aDriveNumber The number of the drive to get the information from. |
144 @param aDriveNumber The number of the drive to get the information from. |
139 */ |
145 */ |
140 void CMassStorageFileSystem::DriveInfo(TDriveInfo& aInfo, TInt aDriveNumber) const |
146 void CMassStorageFileSystem::DriveInfo(TDriveInfo& aInfo, TInt aDriveNumber) const |
141 { |
147 { |
142 __PRINT(_L("CMassStorageFileSystem::DriveInfo In\n")); |
148 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_104); |
143 TLocalDriveCapsV2Buf caps; |
149 TLocalDriveCapsV2Buf caps; |
144 if (!IsValidLocalDriveMapping(aDriveNumber)) |
150 if (!IsValidLocalDriveMapping(aDriveNumber)) |
145 { |
151 { |
146 return; |
152 return; |
147 } |
153 } |
148 (void)GetLocalDrive(aDriveNumber).Caps(caps); |
154 (void)GetLocalDrive(aDriveNumber).Caps(caps); |
149 // error ignored as Caps always returns valid Media and Drive attributes |
155 // error ignored as Caps always returns valid Media and Drive attributes |
150 aInfo.iMediaAtt=caps().iMediaAtt; |
156 aInfo.iMediaAtt=caps().iMediaAtt; |
151 aInfo.iType = ::EMediaNotPresent; // Media is not available to the file system |
157 aInfo.iType = ::EMediaNotPresent; // Media is not available to the file system |
152 aInfo.iDriveAtt=caps().iDriveAtt; |
158 aInfo.iDriveAtt=caps().iDriveAtt; |
153 __PRINT(_L("CMassStorageFileSystem::DriveInfo Out\n")); |
159 } |
154 } |
|
155 |
160 |
156 /** |
161 /** |
157 Returns a reference to the Mass Storage controller. |
162 Returns a reference to the Mass Storage controller. |
158 |
163 |
159 @return Reference to the Mass Storage controller. |
164 @return Reference to the Mass Storage controller. |
160 */ |
165 */ |
161 CUsbMassStorageController& CMassStorageFileSystem::Controller() |
166 CUsbMassStorageController& CMassStorageFileSystem::Controller() |
162 { |
167 { |
163 return *iMassStorageController; |
168 return *iMassStorageController; |
164 } |
169 } |
165 |
170 |
166 /** |
171 /** |
167 Fill iMsDrives with a mapping of lun->drive number for supported mass storage drives |
172 Fill iMsDrives with a mapping of lun->drive number for supported mass storage drives |
168 |
173 |
169 */ |
174 */ |
170 TInt CMassStorageFileSystem::EnumerateMsDrivesL() |
175 TInt CMassStorageFileSystem::EnumerateMsDrivesL() |
171 { |
176 { |
172 __PRINT(_L("CMassStorageFileSystem::EnumerateMsDrives In\n")); |
177 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_105); |
173 iMsDrives.Reset(); |
178 iMsDrives.Reset(); |
174 TInt driveCount = 0; |
179 TInt driveCount = 0; |
175 |
180 |
176 TLocalDriveCapsV2Buf caps; |
181 TLocalDriveCapsV2Buf caps; |
177 for (TInt i = EDriveC; i < KMaxDrives; i++) |
182 for (TInt i = EDriveC; i < KMaxDrives; i++) |
178 { |
183 { |
179 caps.FillZ(); |
184 caps.FillZ(); |
180 |
185 |
181 if (IsValidLocalDriveMapping(i)) |
186 if (IsValidLocalDriveMapping(i)) |
182 { |
187 { |
183 TInt err = GetLocalDrive(i).Caps(caps); |
188 TInt err = GetLocalDrive(i).Caps(caps); |
184 TInt locDrvNum = DriveNumberToLocalDriveNumber(i); |
189 TInt locDrvNum = DriveNumberToLocalDriveNumber(i); |
185 __PRINT2(_L("Caps: err=%d, att=%d\n"), err, caps().iDriveAtt); |
190 OstTraceExt2(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_106, |
186 |
191 "Caps: err=%d, att=%d", err, caps().iDriveAtt); |
187 TBool isRemovable = err==KErrNotReady || (caps().iDriveAtt & KDriveAttRemovable); |
192 |
188 __PRINT2(_L("EnumerateMsDrives: Drive %c: is %sremovable\n"), |
193 TBool isRemovable = err==KErrNotReady || (caps().iDriveAtt & KDriveAttRemovable); |
189 'A'+i-EDriveA, |
194 OstTraceExt2(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_107, |
190 isRemovable?_S(""):_S("NOT ")); |
195 "EnumerateMsDrives: Drive %c: removable %d", 'A'+i-EDriveA, isRemovable); |
191 |
196 |
192 if (isRemovable) |
197 if (isRemovable) |
193 { |
198 { |
194 // |
199 // |
195 // STF: Connect to the local drive here. This gives us the media changed flag, and |
200 // STF: Connect to the local drive here. This gives us the media changed flag, and |
196 // our own TBusLocalDrive object for use by the proxy drive and controller. |
201 // our own TBusLocalDrive object for use by the proxy drive and controller. |
197 // |
202 // |
198 TBool& mediaChanged = (*iMediaChanged).ExtendL(); |
203 TBool& mediaChanged = (*iMediaChanged).ExtendL(); |
199 mediaChanged = EFalse; |
204 mediaChanged = EFalse; |
200 TBusLocalDrive* localDrive = new(ELeave) TBusLocalDrive; |
205 TBusLocalDrive* localDrive = new(ELeave) TBusLocalDrive; |
201 iLocalDriveForMediaFlag.Append(*localDrive); |
206 iLocalDriveForMediaFlag.Append(*localDrive); |
202 |
207 |
203 TInt err=iLocalDriveForMediaFlag[driveCount].Connect(locDrvNum, mediaChanged); |
208 TInt err=iLocalDriveForMediaFlag[driveCount].Connect(locDrvNum, mediaChanged); |
204 if(err == KErrNone) |
209 if(err == KErrNone) |
205 { |
210 { |
206 iMsDrives.Append(i); |
211 iMsDrives.Append(i); |
207 } |
212 } |
208 driveCount++; |
213 driveCount++; |
209 } |
214 } |
210 } |
215 } |
211 } |
216 } |
212 |
217 |
213 __PRINT1(_L("CMassStorageFileSystem::EnumerateMsDrives Out, %d MS drives found\n"), driveCount); |
218 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_108, |
214 return driveCount; |
219 "%d MS drives found", driveCount); |
215 } |
220 return driveCount; |
|
221 } |
216 |
222 |
217 TBool CMassStorageFileSystem::IsExtensionSupported() const |
223 TBool CMassStorageFileSystem::IsExtensionSupported() const |
218 { |
224 { |
219 return ETrue; |
225 return ETrue; |
220 } |
226 } |
221 |
227 |
222 /** |
228 /** |
223 Creates a TrapCleanup and ActiveScheduler and initializes the Mass Storage controller. |
229 Creates a TrapCleanup and ActiveScheduler and initializes the Mass Storage controller. |
224 Start the ActiveScheduler. |
230 Start the ActiveScheduler. |
225 |
231 |
226 @return Any of the standard Symbian error codes. |
232 @return Any of the standard Symbian error codes. |
227 */ |
233 */ |
228 TInt CMassStorageFileSystem::InitThread() |
234 TInt CMassStorageFileSystem::InitThread() |
229 { |
235 { |
230 __PRINT(_L("CMassStorageFileSystem::InitThread In\n")); |
236 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_109); |
231 |
237 |
232 //Give the thread a name so we can kill it later |
238 //Give the thread a name so we can kill it later |
233 User::RenameThread(KMsThreadName); |
239 User::RenameThread(KMsThreadName); |
234 |
240 |
235 CTrapCleanup* cleanup = CTrapCleanup::New(); |
241 CTrapCleanup* cleanup = CTrapCleanup::New(); |
236 if (cleanup == NULL) |
242 if (cleanup == NULL) |
237 { |
243 { |
238 return KErrNoMemory; |
244 return KErrNoMemory; |
239 } |
245 } |
240 |
246 |
241 TRAPD(err, InitThreadL()); |
247 TRAPD(err, InitThreadL()); |
242 |
248 |
243 delete cleanup; |
249 delete cleanup; |
244 |
250 |
245 __PRINT1(_L("CMassStorageFileSystem::InitThread Out, error=%d\n"), err); |
251 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_110, |
246 return err; |
252 "error=%d", err); |
247 } |
253 return err; |
|
254 } |
248 |
255 |
249 TInt CMassStorageFileSystem::InitThreadL() |
256 TInt CMassStorageFileSystem::InitThreadL() |
250 { |
257 { |
251 __PRINT(_L("CMassStorageFileSystem::InitThreadL In\n")); |
258 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_111); |
252 |
259 |
253 RSemaphore gSemThreadReady; |
260 RSemaphore gSemThreadReady; |
254 |
261 |
255 TInt ret = gSemThreadReady.OpenGlobal(KMsFsysSemName); |
262 TInt ret = gSemThreadReady.OpenGlobal(KMsFsysSemName); |
256 |
263 |
257 if (ret != KErrNone && ret != KErrAlreadyExists) |
264 if (ret != KErrNone && ret != KErrAlreadyExists) |
258 { |
265 { |
259 User::Leave(ret); |
266 User::Leave(ret); |
260 } |
267 } |
261 |
268 |
262 // Determine which drives are available for Mass Storage. |
269 // Determine which drives are available for Mass Storage. |
263 // (this also creates a local TBusLocalDrive for use by the drive controller) |
270 // (this also creates a local TBusLocalDrive for use by the drive controller) |
264 EnumerateMsDrivesL(); |
271 EnumerateMsDrivesL(); |
265 |
272 |
266 CActiveScheduler* sched = new CActiveScheduler; |
273 CActiveScheduler* sched = new CActiveScheduler; |
267 if (sched == NULL) |
274 if (sched == NULL) |
268 { |
275 { |
269 gSemThreadReady.Signal(); |
276 gSemThreadReady.Signal(); |
270 User::Leave(KErrNoMemory); |
277 User::Leave(KErrNoMemory); |
271 } |
278 } |
272 CleanupStack::PushL(sched); |
279 CleanupStack::PushL(sched); |
273 CActiveScheduler::Install(sched); |
280 CActiveScheduler::Install(sched); |
274 |
281 |
275 iMassStorageController = new CUsbMassStorageController; |
282 iMassStorageController = new CUsbMassStorageController; |
276 if (iMassStorageController == NULL) |
283 if (iMassStorageController == NULL) |
277 { |
284 { |
278 gSemThreadReady.Signal(); |
285 gSemThreadReady.Signal(); |
279 User::Leave(KErrNoMemory); |
286 User::Leave(KErrNoMemory); |
280 } |
287 } |
281 |
288 |
282 __PRINT(_L("CMassStorageFileSystem::InitThread: Creating Mass Storage Controller\n")); |
289 OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_112, |
283 TRAPD(err, iMassStorageController->CreateL(iMsDrives)); |
290 "Creating Mass Storage Controller"); |
284 if (err != KErrNone) |
291 TRAPD(err, iMassStorageController->CreateL(iMsDrives)); |
285 { |
292 if (err != KErrNone) |
286 gSemThreadReady.Signal(); |
293 { |
287 CActiveScheduler::Install(NULL); |
294 gSemThreadReady.Signal(); |
288 User::Leave(err); |
295 CActiveScheduler::Install(NULL); |
289 } |
296 User::Leave(err); |
290 |
297 } |
291 CleanupStack::Pop(sched); |
298 |
292 |
299 CleanupStack::Pop(sched); |
293 iRunning = ETrue; |
300 |
294 gSemThreadReady.Signal(); |
301 iRunning = ETrue; |
295 gSemThreadReady.Close(); |
302 gSemThreadReady.Signal(); |
296 CActiveScheduler::Start(); |
303 gSemThreadReady.Close(); |
|
304 CActiveScheduler::Start(); |
297 |
305 |
298 //========= stop thread ================ |
306 //========= stop thread ================ |
299 delete iMassStorageController; |
307 OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_113,"thread stopping..."); |
300 iMassStorageController = NULL; |
308 delete iMassStorageController; |
301 TInt i=0; |
309 iMassStorageController = NULL; |
302 for (;i<iLocalDriveForMediaFlag.Count();i++) |
310 TInt i=0; |
303 { |
311 for (;i<iLocalDriveForMediaFlag.Count();i++) |
304 iLocalDriveForMediaFlag[i].Disconnect(); |
312 { |
305 } |
313 iLocalDriveForMediaFlag[i].Disconnect(); |
306 iLocalDriveForMediaFlag.Reset(); |
314 } |
307 (*iMediaChanged).Reset(); |
315 iLocalDriveForMediaFlag.Reset(); |
308 delete sched; |
316 (*iMediaChanged).Reset(); |
309 iRunning = EFalse; |
317 delete sched; |
310 |
318 iRunning = EFalse; |
311 __PRINT(_L("CMassStorageFileSystem::InitThread Out\n")); |
319 OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_114,"thread stopped."); |
312 return KErrNone; |
320 return KErrNone; |
313 } |
321 } |
314 |
322 |
315 /** |
323 /** |
316 Not supported in Mass Storage file system. |
324 Not supported in Mass Storage file system. |
317 |
325 |
318 @leave KErrNotReady |
326 @leave KErrNotReady |
319 */ |
327 */ |
320 CFileCB* CMassStorageFileSystem::NewFileL() const |
328 CFileCB* CMassStorageFileSystem::NewFileL() const |
321 { |
329 { |
322 __PRINT(_L("CMassStorageFileSystem::NewFileL In\n")); |
330 User::Leave(KErrNotReady); |
323 User::Leave(KErrNotReady); |
331 return NULL; |
324 return NULL; |
332 } |
325 } |
|
326 |
333 |
327 /** |
334 /** |
328 Not supported in Mass Storage file system. |
335 Not supported in Mass Storage file system. |
329 |
336 |
330 @leave KErrNotReady |
337 @leave KErrNotReady |
331 */ |
338 */ |
332 CDirCB* CMassStorageFileSystem::NewDirL() const |
339 CDirCB* CMassStorageFileSystem::NewDirL() const |
333 { |
340 { |
334 User::Leave(KErrNotReady); |
341 User::Leave(KErrNotReady); |
335 return NULL; |
342 return NULL; |
336 } |
343 } |
337 |
344 |
338 /** |
345 /** |
339 Not supported in Mass Storage file system. |
346 Not supported in Mass Storage file system. |
340 |
347 |
341 @leave KErrNotReady |
348 @leave KErrNotReady |
342 */ |
349 */ |
343 CFormatCB* CMassStorageFileSystem::NewFormatL() const |
350 CFormatCB* CMassStorageFileSystem::NewFormatL() const |
344 { |
351 { |
345 User::Leave(KErrNotReady); |
352 User::Leave(KErrNotReady); |
346 return NULL; |
353 return NULL; |
347 } |
354 } |
348 |
355 |
349 /** |
356 /** |
350 Not supported in Mass Storage file system. |
357 Not supported in Mass Storage file system. |
351 |
358 |
352 @return KErrNotSupported |
359 @return KErrNotSupported |
353 */ |
360 */ |
354 TInt CMassStorageFileSystem::DefaultPath(TDes& /*aPath*/) const |
361 TInt CMassStorageFileSystem::DefaultPath(TDes& /*aPath*/) const |
355 { |
362 { |
356 return KErrNotSupported; |
363 return KErrNotSupported; |
357 } |
364 } |
358 |
365 |
359 /** |
366 /** |
360 Not supported in Mass Storage file system. |
367 Not supported in Mass Storage file system. |
361 |
368 |
362 @return KErrNotSupported |
369 @return KErrNotSupported |
363 */ |
370 */ |
364 TInt CMassStorageFileSystem::DriveList(TDriveList& /*aList*/) const |
371 TInt CMassStorageFileSystem::DriveList(TDriveList& /*aList*/) const |
365 { |
372 { |
366 return KErrNotSupported; |
373 return KErrNotSupported; |
367 } |
374 } |
368 |
375 |
369 /** |
376 /** |
370 Thread entry point. |
377 Thread entry point. |
371 */ |
378 */ |
372 LOCAL_C TInt MsInitThreadFn(TAny* aPtr) |
379 static TInt MsInitThreadFn(TAny* aPtr) |
373 { |
380 { |
374 User::SetCritical(User::ESystemCritical); |
381 User::SetCritical(User::ESystemCritical); |
375 ((CMassStorageFileSystem*)aPtr)->InitThread(); |
382 ((CMassStorageFileSystem*)aPtr)->InitThread(); |
376 //Rename the thread so we can create a new one with the same original name later |
383 //Rename the thread so we can create a new one with the same original name later |
377 User::RenameThread(KMsDeadThreadName); |
384 User::RenameThread(KMsDeadThreadName); |
378 return KErrNone; |
385 return KErrNone; |
379 } |
386 } |
380 |
387 |
381 /** |
388 /** |
382 Standard entry point for file systems. |
389 Standard entry point for file systems. |
383 Creates a new file system object and starts a new thread for the Mass Storage controller. |
390 Creates a new file system object and starts a new thread for the Mass Storage controller. |
384 */ |
391 */ |
385 extern "C" EXPORT_C CFileSystem* CreateFileSystem() |
392 extern "C" EXPORT_C CFileSystem* CreateFileSystem() |
386 { |
393 { |
387 __PRINT(_L("CMassStorageFileSystem::CreateFileSystem In\n")); |
394 OstTraceFunctionEntry0(CMASSSTORAGEFILESYSTEM_115); |
388 RSemaphore gSemThreadReady; |
395 RSemaphore gSemThreadReady; |
389 TInt err = gSemThreadReady.CreateGlobal(KMsFsysSemName, 0); |
396 TInt err = gSemThreadReady.CreateGlobal(KMsFsysSemName, 0); |
390 if (err != KErrNone) |
397 if (err != KErrNone) |
391 { |
398 { |
392 __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out Semaphore Error %d\n"),err); |
399 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_116, |
393 return NULL; |
400 "Semaphore CreateGlobal Error %d", err); |
394 } |
401 return NULL; |
395 |
402 } |
396 CFileSystem* msFsys = NULL; |
403 |
397 TRAP(err, msFsys = CMassStorageFileSystem::NewL()); |
404 CFileSystem* msFsys = NULL; |
398 if (err != KErrNone) |
405 TRAP(err, msFsys = CMassStorageFileSystem::NewL()); |
399 { |
406 if (err != KErrNone) |
400 __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out MSFS Error %d\n"),err); |
407 { |
401 gSemThreadReady.Close(); |
408 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_117, |
402 return NULL; |
409 "MSFS Error %d",err); |
403 } |
410 gSemThreadReady.Close(); |
404 |
411 return NULL; |
405 RThread msThread; |
412 } |
406 __PRINT(_L("CMassStorageFileSystem::CreateFileSystem: Creating Mass Storage thread\n")); |
413 |
407 err = msThread.Create(KMsThreadName, MsInitThreadFn, KDefaultStackSize, NULL, msFsys); |
414 RThread msThread; |
408 if (err != KErrNone) |
415 OstTrace0(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_118, |
409 { |
416 "Creating Mass Storage thread..."); |
410 __PRINT1(_L("CMassStorageFileSystem::CreateFileSystem Out Thread Error %d\n"),err); |
417 err = msThread.Create(KMsThreadName, MsInitThreadFn, KDefaultStackSize, NULL, msFsys); |
411 gSemThreadReady.Close(); |
418 if (err != KErrNone) |
412 return msFsys; |
419 { |
413 } |
420 OstTrace1(TRACE_SMASSSTORAGE_FS, CMASSSTORAGEFILESYSTEM_119, |
414 ((CMassStorageFileSystem*)msFsys)->iInstalled=ETrue; |
421 "Thread Error %d", err); |
415 |
422 gSemThreadReady.Close(); |
416 |
423 return msFsys; |
417 msThread.Logon(((CMassStorageFileSystem*)msFsys)->iThreadStat); |
424 } |
418 msThread.Resume(); |
425 ((CMassStorageFileSystem*)msFsys)->iInstalled=ETrue; |
419 gSemThreadReady.Wait(); |
426 |
420 gSemThreadReady.Close(); |
427 |
421 msThread.Close(); |
428 msThread.Logon(((CMassStorageFileSystem*)msFsys)->iThreadStat); |
422 |
429 msThread.Resume(); |
423 __PRINT(_L("CMassStorageFileSystem::CreateFileSystem Out Clean\n")); |
430 gSemThreadReady.Wait(); |
424 |
431 gSemThreadReady.Close(); |
425 return msFsys; |
432 msThread.Close(); |
426 } |
433 return msFsys; |
427 |
434 } |
|
435 |