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