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