author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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 |
// e32test\lffs\loadlffs.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <f32file.h> |
|
19 |
||
20 |
LOCAL_D RFs TheFs; |
|
21 |
||
22 |
LOCAL_C void FormatLFFS(TDes &drive) |
|
23 |
{ |
|
24 |
||
25 |
RFormat format; |
|
26 |
TInt count; |
|
27 |
||
28 |
RDebug::Print(_L("Format LFFS drive %S\r\n"), &drive); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
format.Open(TheFs, drive, EHighDensity, count); |
0 | 30 |
|
31 |
while (count) |
|
32 |
{ |
|
33 |
format.Next(count); |
|
34 |
} |
|
35 |
||
36 |
format.Close(); |
|
37 |
} |
|
38 |
||
39 |
||
40 |
//LOCAL_C void ForceMediaRemount( TMediaDevice aMedia ) |
|
41 |
// // |
|
42 |
// // Force a remount on next access |
|
43 |
// // |
|
44 |
// { |
|
45 |
// UserSvr::ForceRemountMedia( aMedia ); |
|
46 |
// } |
|
47 |
||
48 |
||
49 |
||
50 |
TInt MountLFFS() |
|
51 |
{ |
|
52 |
RDebug::Print(_L("Read machine information")); |
|
53 |
||
54 |
TInt LFFSdriveNumber; |
|
55 |
TBuf<4> LFFSdriveLetter; |
|
56 |
||
57 |
LFFSdriveLetter.Zero(); |
|
58 |
LFFSdriveLetter.Append(_L("K:\\")); |
|
59 |
LFFSdriveNumber = EDriveK; |
|
60 |
||
61 |
RDebug::Print(_L("Load device driver: MEDLFS")); |
|
62 |
TInt r=User::LoadPhysicalDevice(_L("MEDLFS")); |
|
63 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
64 |
{ |
|
65 |
RDebug::Print(_L("Loading device driver failed")); |
|
66 |
return(-1); |
|
67 |
} |
|
68 |
||
69 |
RDebug::Print(_L("Add file system: ELFFS")); |
|
70 |
r=TheFs.AddFileSystem(_L("ELFFS")); |
|
71 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
72 |
RDebug::Print(_L("Failed to add ELFFS")); |
|
73 |
||
74 |
||
75 |
TFullName name; |
|
76 |
r = TheFs.FileSystemName(name, LFFSdriveNumber); |
|
77 |
||
78 |
if (name.Length() != 0) |
|
79 |
{ |
|
80 |
RDebug::Print(_L("Dismounting %S on drive %S\r\n"), &name, &LFFSdriveLetter); |
|
81 |
r=TheFs.DismountFileSystem(name, LFFSdriveNumber); |
|
82 |
RDebug::Print(_L("Dismount ret=%d"), r); |
|
83 |
} |
|
84 |
||
85 |
// ForceMediaRemount( EFixedMedia1 ); |
|
86 |
||
87 |
RDebug::Print(_L("Mount LFFS on drive %S\r\n"), &LFFSdriveLetter); |
|
88 |
r=TheFs.MountFileSystem(_L("Lffs"), LFFSdriveNumber); |
|
89 |
RDebug::Print(_L("Mount r=%d"),r); |
|
90 |
//uncommented |
|
91 |
if (r == KErrCorrupt || r == KErrNotReady) |
|
92 |
{ |
|
93 |
RDebug::Print(_L("FS Corrupt, formatting")); |
|
94 |
FormatLFFS(LFFSdriveLetter); |
|
95 |
} |
|
96 |
///to here |
|
97 |
TheFs.SetSessionPath(LFFSdriveLetter); |
|
98 |
return(LFFSdriveNumber); |
|
99 |
} |
|
100 |
||
101 |
GLDEF_C TInt E32Main() |
|
102 |
// |
|
103 |
// Load the LFFS on C: |
|
104 |
// |
|
105 |
{ |
|
106 |
||
107 |
CTrapCleanup* cleanup; |
|
108 |
cleanup=CTrapCleanup::New(); |
|
109 |
||
110 |
TInt r=TheFs.Connect(); |
|
111 |
RDebug::Print(_L("Connect ret %d"),r); |
|
112 |
||
113 |
TRAP(r,MountLFFS()); |
|
114 |
RDebug::Print(_L("Mount LFFS ret %d"),r); |
|
115 |
||
116 |
TheFs.Close(); |
|
117 |
delete cleanup; |
|
118 |
return(KErrNone); |
|
119 |
} |
|
120 |