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