|
1 // Copyright (c) 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 // Class declaration for CMassStorageMountCB. |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef __CMASSSTORAGEMOUNTCB_H__ |
|
26 #define __CMASSSTORAGEMOUNTCB_H__ |
|
27 |
|
28 #include <f32fsys.h> |
|
29 |
|
30 /** |
|
31 Mass Storage Mount. |
|
32 Only the MountL, Dismounted and Unlock methods are supported. All other methods |
|
33 leave with KErrNotReady. |
|
34 ControlIO is also supported for debug builds and returns KErrNotSupported for Release builds. |
|
35 @internalTechnology |
|
36 */ |
|
37 class TFatBootSector; |
|
38 class CMassStorageMountCB : public CLocDrvMountCB |
|
39 { |
|
40 public: |
|
41 static CMassStorageMountCB* NewL(const TLunToDriveMap& aDriveMapping); |
|
42 void MountL(TBool aForceMount); |
|
43 TInt ReMount(); |
|
44 void Dismounted(); |
|
45 void VolumeL(TVolumeInfo& aVolume) const; |
|
46 void SetVolumeL(TDes& aName); |
|
47 void MkDirL(const TDesC& aName); |
|
48 void RmDirL(const TDesC& aName); |
|
49 void DeleteL(const TDesC& aName); |
|
50 void RenameL(const TDesC& anOldName,const TDesC& anNewName); |
|
51 void ReplaceL(const TDesC& anOldName,const TDesC& anNewName); |
|
52 void EntryL(const TDesC& aName,TEntry& anEntry) const; |
|
53 void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aSetAttMask,TUint aClearAttMask); |
|
54 void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile); |
|
55 void DirOpenL(const TDesC& aName,CDirCB* aDir); |
|
56 void RawReadL(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt anOffset, const RMessagePtr2& aMessage) const; |
|
57 void RawWriteL(TInt64 aPos, TInt aLength, const TAny* aTrg, TInt anOffset, const RMessagePtr2& aMessage); |
|
58 void ReadSectionL(const TDesC& aName, TInt aPos, TAny* aTrg, TInt aLength, const RMessagePtr2& aMessage); |
|
59 void GetShortNameL(const TDesC& aLongName,TDes& aShortName); |
|
60 void GetLongNameL(const TDesC& aShorName,TDes& aLongName); |
|
61 TInt ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2); |
|
62 TInt Unlock(TMediaPassword& aPassword, TBool aStore); |
|
63 |
|
64 private: |
|
65 CMassStorageMountCB(const TLunToDriveMap& aDriveMapping); |
|
66 void WritePasswordData(); |
|
67 TInt DriveNumberToLun(TInt aDriveNumber); |
|
68 TBool ValidateBootSector(); |
|
69 TInt ReadBootSector(TFatBootSector& aBootSector); |
|
70 TInt DetermineFatType(TFatBootSector& aBootSector); |
|
71 TInt CheckDriveNumberL(); |
|
72 |
|
73 TBool IsPowerOfTwo(TInt aNum); |
|
74 TInt Log2(TInt aNum); |
|
75 |
|
76 private: |
|
77 TBool iIs16BitFat; |
|
78 TBool iIs32BitFat; |
|
79 const TLunToDriveMap& iDriveMapping; |
|
80 }; |
|
81 |
|
82 const TInt KSizeOfFatBootSector = 90; |
|
83 const TInt KVendorIdSize = 8; |
|
84 const TInt KVolumeLabelSize = 11; |
|
85 const TInt KFileSysTypeSize = 8; |
|
86 const TInt KBootSectorSignature = 0xAA55; |
|
87 const TInt KSizeOfFatDirEntry = 32; |
|
88 |
|
89 /** |
|
90 Boot sector parameter block, enables access to all file system parameters. |
|
91 Data is populated at mount time from the BPB sector |
|
92 @internalTechnology |
|
93 */ |
|
94 class TFatBootSector |
|
95 { |
|
96 public: |
|
97 inline const TPtrC8 VendorId() const; |
|
98 inline TUint16 BytesPerSector() const; |
|
99 inline TInt SectorsPerCluster() const; |
|
100 inline TInt ReservedSectors() const; |
|
101 inline TInt NumberOfFats() const; |
|
102 inline TInt RootDirEntries() const; |
|
103 inline TInt TotalSectors() const; |
|
104 inline TUint8 MediaDescriptor() const; |
|
105 inline TInt FatSectors() const; |
|
106 inline TInt SectorsPerTrack() const; |
|
107 inline TInt NumberOfHeads() const; |
|
108 inline TInt HiddenSectors() const; |
|
109 inline TInt HugeSectors() const; |
|
110 inline TInt PhysicalDriveNumber() const; |
|
111 inline TInt ExtendedBootSignature() const; |
|
112 inline TUint32 UniqueID() const; |
|
113 inline const TPtrC8 VolumeLabel() const; |
|
114 inline const TPtrC8 FileSysType() const; |
|
115 inline TInt BootSectorSignature() const; |
|
116 inline void SetJumpInstruction(); |
|
117 inline void SetVendorID(const TDesC8& aDes); |
|
118 inline void SetBytesPerSector(TInt aBytesPerSector); |
|
119 inline void SetSectorsPerCluster(TInt aSectorsPerCluster); |
|
120 inline void SetReservedSectors(TInt aReservedSectors); |
|
121 inline void SetNumberOfFats(TInt aNumberOfFats); |
|
122 inline void SetRootDirEntries(TInt aRootDirEntries); |
|
123 inline void SetTotalSectors(TInt aTotalSectors); |
|
124 inline void SetMediaDescriptor(TUint8 aMediaDescriptor); |
|
125 inline void SetFatSectors(TInt aFatSectors); |
|
126 inline void SetSectorsPerTrack(TInt aSectorsPerTrack); |
|
127 inline void SetNumberOfHeads(TInt aNumberOfHeads); |
|
128 inline void SetHiddenSectors(TUint32 aHiddenSectors); |
|
129 inline void SetHugeSectors(TUint32 aTotalSectors); |
|
130 inline void SetPhysicalDriveNumber(TInt aPhysicalDriveNumber); |
|
131 inline void SetReservedByte(TUint8 aReservedByte); |
|
132 inline void SetExtendedBootSignature(TInt anExtendedBootSignature); |
|
133 inline void SetUniqueID(TUint32 anUniqueID); |
|
134 inline void SetVolumeLabel(const TDesC8& aDes); |
|
135 inline void SetFileSysType(const TDesC8& aDes); |
|
136 |
|
137 inline void SetFatSectors32(TUint32 aFatSectors32); |
|
138 inline void SetFATFlags(TUint16 aFATFlags); |
|
139 inline void SetVersionNumber(TUint16 aVersionNumber); |
|
140 inline void SetRootClusterNum(TUint32 aRootCusterNum); |
|
141 inline void SetFSInfoSectorNum(TUint16 aFSInfoSectorNum); |
|
142 inline void SetBkBootRecSector(TUint16 aBkBootRecSector); |
|
143 inline TUint32 FatSectors32() const; |
|
144 inline TUint16 FATFlags() const; |
|
145 inline TUint16 VersionNumber() const; |
|
146 inline TUint32 RootClusterNum() const; |
|
147 inline TUint16 FSInfoSectorNum() const; |
|
148 inline TUint16 BkBootRecSector() const; |
|
149 public: |
|
150 inline TBool Is16BitFat(); |
|
151 inline TBool Is32BitFat(); |
|
152 inline TInt FirstFatSectorPos(); |
|
153 inline TInt RootDirStartSector(); |
|
154 inline TInt FirstFreeSector(); |
|
155 public: |
|
156 /** |
|
157 Jump instruction used for bootable volumes |
|
158 */ |
|
159 TUint8 iJumpInstruction[3]; |
|
160 /** |
|
161 Vendor ID of the file system that formatted the volume |
|
162 */ |
|
163 TUint8 iVendorId[KVendorIdSize]; |
|
164 /** |
|
165 Bytes per sector |
|
166 */ |
|
167 TUint16 iBytesPerSector; |
|
168 /** |
|
169 Sectors per cluster ratio |
|
170 */ |
|
171 TUint8 iSectorsPerCluster; |
|
172 /** |
|
173 Number of reserved sectors on the volume |
|
174 */ |
|
175 TUint16 iReservedSectors; |
|
176 /** |
|
177 Number of Fats on the volume |
|
178 */ |
|
179 TUint8 iNumberOfFats; |
|
180 /** |
|
181 Number of entries allowed in the root directory, specific to Fat12/16, zero for FAT32 |
|
182 */ |
|
183 TUint16 iRootDirEntries; |
|
184 /** |
|
185 Total sectors on the volume, zero for FAT32 |
|
186 */ |
|
187 TUint16 iTotalSectors; |
|
188 /** |
|
189 Media descriptor |
|
190 */ |
|
191 TUint8 iMediaDescriptor; |
|
192 /** |
|
193 Sectors used for the Fat table, zero for FAT32 |
|
194 */ |
|
195 TUint16 iFatSectors; |
|
196 /** |
|
197 Sectors per track |
|
198 */ |
|
199 TUint16 iSectorsPerTrack; |
|
200 /** |
|
201 Number of heads |
|
202 */ |
|
203 TUint16 iNumberOfHeads; |
|
204 /** |
|
205 Number of hidden sectors in the volume |
|
206 */ |
|
207 TUint32 iHiddenSectors; |
|
208 /** |
|
209 Total sectors in the volume, Used if totalSectors > 65535 |
|
210 */ |
|
211 TUint32 iHugeSectors; |
|
212 |
|
213 /** |
|
214 Start of additional elements @ offset 36 for FAT32 |
|
215 Sectors in Fat table for 32 bit volume |
|
216 */ |
|
217 TUint32 iFatSectors32; |
|
218 /** |
|
219 Fat flags |
|
220 */ |
|
221 TUint16 iFATFlags; |
|
222 /** |
|
223 Version number of the file system |
|
224 */ |
|
225 TUint16 iVersionNumber; |
|
226 /** |
|
227 Cluster number of the root directory |
|
228 */ |
|
229 TUint32 iRootClusterNum; |
|
230 /** |
|
231 Sector number containing the FSIInfo structure |
|
232 */ |
|
233 TUint16 iFSInfoSectorNum; |
|
234 /** |
|
235 Backup boot sector |
|
236 */ |
|
237 TUint16 iBkBootRecSector; |
|
238 /** |
|
239 Reserved space |
|
240 End of Fat32 Only parameters section |
|
241 */ |
|
242 TUint8 iReserved2[12]; |
|
243 |
|
244 /** |
|
245 Physical drive number, not used in Symbian OS |
|
246 */ |
|
247 TUint8 iPhysicalDriveNumber; |
|
248 /** |
|
249 Reserved byte |
|
250 */ |
|
251 TUint8 iReserved; |
|
252 /** |
|
253 Extended boot signiture |
|
254 */ |
|
255 TUint8 iExtendedBootSignature; |
|
256 /** |
|
257 Unique volume ID |
|
258 */ |
|
259 TUint32 iUniqueID; |
|
260 /** |
|
261 The volume's label |
|
262 */ |
|
263 TUint8 iVolumeLabel[KVolumeLabelSize]; |
|
264 /** |
|
265 File system type |
|
266 */ |
|
267 TUint8 iFileSysType[KFileSysTypeSize]; |
|
268 }; |
|
269 |
|
270 #include "tfatbootsector.inl" |
|
271 |
|
272 #endif //__CMASSSTORAGEMOUNTCB_H__ |