1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfat32/inc/sl_std.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1066 @@
1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// fileserver\sfat32\inc\sl_std.h
1.18 +//
1.19 +
1.20 +/**
1.21 + @file
1.22 + @internalTechnology
1.23 +*/
1.24 +
1.25 +#ifndef SL_STD_H
1.26 +#define SL_STD_H
1.27 +
1.28 +
1.29 +//
1.30 +// #define _DEBUG_RELEASE
1.31 +//
1.32 +
1.33 +#include "common.h"
1.34 +#include <f32ver.h>
1.35 +#include <e32svr.h>
1.36 +#include <kernel/localise.h>
1.37 +
1.38 +#include "filesystem_fat.h"
1.39 +using namespace FileSystem_FAT;
1.40 +
1.41 +#include "common_constants.h"
1.42 +#include "sl_bpb.h"
1.43 +#include "fat_config.h"
1.44 +#include "fat_dir_entry.h"
1.45 +#include "bit_vector.h"
1.46 +
1.47 +
1.48 +
1.49 +#ifdef _DEBUG
1.50 +_LIT(KThisFsyName,"EFAT32.FSY"); ///< This FSY name
1.51 +#endif
1.52 +
1.53 +//-----------------------------------------------------------------------------
1.54 +//-- FAT32 specific declarations
1.55 +
1.56 +const TUint32 KFat32EntryMask = 0x0FFFFFFF;
1.57 +
1.58 +//-----------------------------------------------------------------------------
1.59 +
1.60 +class CFatMountCB;
1.61 +class CFatFileSystem;
1.62 +
1.63 +/**
1.64 +Represents the position of a directory entery in terms of a cluster and off set into it
1.65 +*/
1.66 +class TEntryPos
1.67 + {
1.68 +public:
1.69 + TEntryPos() {}
1.70 + TEntryPos(TInt aCluster,TUint aPos) : iCluster(aCluster), iPos(aPos) {}
1.71 +
1.72 + inline TUint32 Cluster() const;
1.73 + inline TUint32 Pos() const;
1.74 + inline TBool operator==(const TEntryPos& aRhs) const;
1.75 +
1.76 +public:
1.77 + TInt iCluster;
1.78 + TUint iPos;
1.79 + };
1.80 +
1.81 +
1.82 +/**
1.83 + Interface class between the file system and the local drive media interface,
1.84 + handles incomplete writes to media with the ability to notify the user.
1.85 + This class can't be instantinated by user; only CFatMountCB can do this; see CFatMountCB::DriveInterface()
1.86 +
1.87 +*/
1.88 +class TDriveInterface
1.89 + {
1.90 +public:
1.91 + enum TAction {ERetry=1};
1.92 +
1.93 +public:
1.94 +
1.95 + //-- public interface to the local drive. Provides media driver's error handling (critical and non-critical user notifiers)
1.96 + //-- and thread-safety if required.
1.97 + TInt ReadNonCritical(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const;
1.98 + TInt ReadNonCritical(TInt64 aPos,TInt aLength,TDes8& aTrg) const;
1.99 + TInt ReadCritical(TInt64 aPos,TInt aLength,TDes8& aTrg) const;
1.100 +
1.101 + TInt WriteCritical(TInt64 aPos,const TDesC8& aSrc);
1.102 + TInt WriteNonCritical(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset);
1.103 +
1.104 + TInt GetLastErrorInfo(TDes8& aErrorInfo) const;
1.105 +
1.106 + //-- lock the mutex guarding CProxyDrive interface in order to be sure that no other thread can access it.
1.107 + //-- The thread that calls this method may be suspended until another signals the mutex, i.e. leaves the critical section.
1.108 + inline void AcquireLock() const {iProxyDrive.EnterCriticalSection();}
1.109 +
1.110 + //-- release the mutex guarding CProxyDrive.
1.111 + inline void ReleaseLock() const {iProxyDrive.LeaveCriticalSection();}
1.112 +
1.113 +
1.114 +protected:
1.115 + TDriveInterface();
1.116 + TDriveInterface(const TDriveInterface&);
1.117 + TDriveInterface& operator=(const TDriveInterface&);
1.118 +
1.119 + TBool Init(CFatMountCB* aMount);
1.120 + void Close();
1.121 +
1.122 + inline TBool NotifyUser() const;
1.123 + TInt HandleRecoverableError(TInt aRes) const;
1.124 + TInt HandleCriticalError(TInt aRes) const;
1.125 + TInt UnlockAndReMount() const;
1.126 + TBool IsDriveWriteProtected() const;
1.127 + TBool IsRecoverableRemount() const;
1.128 +
1.129 +private:
1.130 +
1.131 + /**
1.132 + An internal class that represents a thread-safe wrapper around raw interface to the CProxyDrive
1.133 + and restricts access to it.
1.134 + */
1.135 + class XProxyDriveWrapper
1.136 + {
1.137 + public:
1.138 +
1.139 + XProxyDriveWrapper();
1.140 + ~XProxyDriveWrapper();
1.141 +
1.142 + TBool Init(CProxyDrive* aProxyDrive);
1.143 +
1.144 + inline void EnterCriticalSection() const {iLock.Wait();}
1.145 + inline void LeaveCriticalSection() const {iLock.Signal();}
1.146 +
1.147 + //-- methods' wrappers that are used by TDriveInterface
1.148 + TInt Read(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const;
1.149 + TInt Read(TInt64 aPos,TInt aLength,TDes8& aTrg) const;
1.150 + TInt Write(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset);
1.151 + TInt Write(TInt64 aPos, const TDesC8& aSrc);
1.152 + TInt GetLastErrorInfo(TDes8& aErrorInfo) const;
1.153 + TInt Caps(TDes8& anInfo) const;
1.154 +
1.155 + private:
1.156 + CProxyDrive* iLocalDrive; ///< raw interface to the media operations
1.157 + mutable RMutex iLock; ///< used for sorting out multithreaded access to the iLocalDrive
1.158 + };
1.159 +
1.160 + CFatMountCB* iMount; ///< Pointer to the owning file system mount
1.161 + XProxyDriveWrapper iProxyDrive; ///< wrapper around raw interface to the media operations
1.162 +
1.163 + };
1.164 +
1.165 +
1.166 +/**
1.167 + Class providing FAT table interface and basic functionality.
1.168 +*/
1.169 +class CFatTable : public CBase
1.170 + {
1.171 +
1.172 +public:
1.173 +
1.174 + virtual ~CFatTable();
1.175 +
1.176 + static CFatTable* NewL(CFatMountCB& aOwner, const TLocalDriveCaps& aLocDrvCaps);
1.177 +
1.178 + /** FAT table mounting parameters */
1.179 + struct TMountParams
1.180 + {
1.181 + TMountParams() :iFreeClusters(0), iFirstFreeCluster(0), iFsInfoValid(0) {};
1.182 +
1.183 + TUint32 iFreeClusters; ///< Free clusters count, obtained from FSInfo
1.184 + TUint32 iFirstFreeCluster; ///< First free cluster, obtained from FSInfo
1.185 + TUint32 iFsInfoValid : 1; ///< ETrue if the information in iFreeClusters & iFirstFreeCluster is valid
1.186 + };
1.187 +
1.188 + //-----------------------------------------------------------------
1.189 + //-- pure virtual interface
1.190 + virtual TUint32 ReadL(TUint32 aFatIndex) const = 0;
1.191 + virtual void WriteL(TUint32 aFatIndex, TUint32 aValue) = 0;
1.192 + virtual TInt64 DataPositionInBytes(TUint32 aCluster) const = 0;
1.193 + virtual void MountL(const TMountParams& aMountParam) = 0;
1.194 + //-----------------------------------------------------------------
1.195 + //-- just virtual interface
1.196 +
1.197 + virtual void Dismount(TBool /*aDiscardDirtyData*/) {}
1.198 + virtual void FlushL() {};
1.199 +
1.200 + virtual void InvalidateCacheL() {};
1.201 + virtual void InvalidateCacheL(TInt64 /*aPos*/,TUint32 /*aLength*/) {};
1.202 +
1.203 + virtual void FreeClusterListL(TUint32 aCluster);
1.204 + virtual void ExtendClusterListL(TUint32 aNumber,TInt& aCluster);
1.205 +
1.206 + virtual TUint32 AllocateSingleClusterL(TUint32 aNearestCluster);
1.207 + virtual TUint32 AllocateClusterListL(TUint32 aNumber,TUint32 aNearestCluster);
1.208 +
1.209 + virtual void RequestRawWriteAccess(TInt64 /*aPos*/, TUint32 /*aLen*/) const {};
1.210 +
1.211 + virtual TUint32 FreeClusterHint() const;
1.212 + virtual TUint32 NumberOfFreeClusters(TBool aSyncOperation=EFalse) const;
1.213 + virtual TBool RequestFreeClusters(TUint32 aClustersRequired) const;
1.214 +
1.215 + virtual void InitializeL();
1.216 + virtual TBool ConsistentState() const {return ETrue;} //-- dummy
1.217 +
1.218 + //-----------------------------------------------------------------
1.219 + //-- non-virtual interface
1.220 + TBool GetNextClusterL(TInt& aCluster) const;
1.221 + void WriteFatEntryEofL(TUint32 aFatIndex);
1.222 +
1.223 + void MarkAsBadClusterL(TUint32 aCluster);
1.224 + TInt CountContiguousClustersL(TUint32 aStartCluster,TInt& anEndCluster, TUint32 aMaxCount) const;
1.225 +
1.226 + inline TUint32 MaxEntries() const;
1.227 +
1.228 + TUint32 PosInBytes(TUint32 aFatIndex) const;
1.229 +
1.230 +
1.231 +protected:
1.232 + CFatTable(CFatMountCB& aOwner);
1.233 +
1.234 + //-- outlawed
1.235 + CFatTable();
1.236 + CFatTable(const CFatTable&);
1.237 + CFatTable& operator=(const CFatTable&);
1.238 +
1.239 + virtual void SetFreeClusterHint(TUint32 aCluster);
1.240 +
1.241 + virtual void DecrementFreeClusterCount(TUint32 aCount);
1.242 + virtual void IncrementFreeClusterCount(TUint32 aCount);
1.243 +
1.244 + virtual void SetFreeClusters(TUint32 aFreeClusters);
1.245 + virtual void CountFreeClustersL();
1.246 + virtual TUint32 FindClosestFreeClusterL(TUint32 aCluster);
1.247 +
1.248 +
1.249 + inline TInt SectorSizeLog2() const;
1.250 + inline TUint32 FreeClusters() const;
1.251 +
1.252 + inline TBool IsEndOfClusterCh(TUint32 aCluster) const;
1.253 +
1.254 +
1.255 + inline TFatType FatType() const;
1.256 + inline TBool IsFat12() const;
1.257 + inline TBool IsFat16() const;
1.258 + inline TBool IsFat32() const;
1.259 +
1.260 +
1.261 + inline TBool ClusterNumberValid(TUint32 aClusterNo) const;
1.262 +
1.263 + typedef RArray<TUint> RClusterArray;
1.264 + void DoFreedClustersNotify(RClusterArray &aFreedClusters);
1.265 +
1.266 +
1.267 +protected:
1.268 +
1.269 + CFatMountCB* iOwner; ///< Owning file system mount
1.270 + TUint iMediaAtt; ///< Cached copy of TLocalDriveCaps::iMediaAtt
1.271 +
1.272 +private:
1.273 +
1.274 + TUint32 iFreeClusters; ///< Number of free cluster in the fat table
1.275 + TUint32 iFreeClusterHint; ///< this is just a hint to the free cluster number, not required to contain exact information.
1.276 + TFatType iFatType; ///< FAT type 12/16/32, cached from the iOwner
1.277 + TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32
1.278 + TUint32 iMaxEntries; ///< maximal number of FAT entries in the table. This value is taken from the CFatMount that calculates it
1.279 +
1.280 + };
1.281 +
1.282 +
1.283 +class MWTCacheInterface;
1.284 +
1.285 +
1.286 +//---------------------------------------------------------------------------------------------------------------------------------
1.287 +
1.288 +/**
1.289 +Base class abstraction of a raw media disk
1.290 +*/
1.291 +
1.292 +
1.293 +class CRawDisk : public CBase
1.294 + {
1.295 +public:
1.296 +
1.297 + static CRawDisk* NewL(CFatMountCB& aOwner, const TLocalDriveCaps& aLocDrvCaps);
1.298 +
1.299 + virtual void InitializeL();
1.300 +
1.301 + virtual TInt GetLastErrorInfo(TDes8& aErrorInfo) const;
1.302 +public:
1.303 +
1.304 + /**
1.305 + Read data from the media via simple WT data cache if it is present. Some media types, like RAM do not have caches.
1.306 + This method is mostly used to read UIDs of executable modules and store them in the cache.
1.307 +
1.308 + @param aPos Media position in bytes
1.309 + @param aLength Length in bytes of read
1.310 + @param aDes Data from read
1.311 + */
1.312 + virtual void ReadCachedL(TInt64 aPos,TInt aLength,TDes8& aDes) const = 0;
1.313 +
1.314 + /**
1.315 + Write data to the media via simple WT data cache if it is present. Some media types, like RAM do not have caches.
1.316 + @param aPos Media position in bytes
1.317 + @param aDes Data to write
1.318 + */
1.319 + virtual void WriteCachedL(TInt64 aPos,const TDesC8& aDes) = 0;
1.320 +
1.321 + virtual void InvalidateUidCache() {}
1.322 + virtual void InvalidateUidCachePage(TUint64 /*aPos*/) {}
1.323 +
1.324 +
1.325 + /**
1.326 + Disk read function
1.327 +
1.328 + @param aPos Media position in bytes
1.329 + @param aLength Length in bytes of read
1.330 + @param aTrg Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
1.331 + @param aMessage Refrence to server message from request
1.332 + @param anOffset Offset into read data to write
1.333 + */
1.334 + virtual void ReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2 &aMessage,TInt anOffset) const = 0;
1.335 +
1.336 + /**
1.337 + Disk write function
1.338 +
1.339 + @param aPos Media position in bytes
1.340 + @param aLength Length in bytes of write
1.341 + @param aTrg Pointer to the data descriptor, i.e. (const TAny*)(&TDes8)
1.342 + @param aMessage Refrence to server message from request, contains data
1.343 + @param anOffset Offset into write data to use in write
1.344 + */
1.345 + virtual void WriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2 &aMessage,TInt anOffset) = 0;
1.346 +
1.347 +
1.348 + virtual inline MWTCacheInterface* DirCacheInterface();
1.349 +
1.350 +
1.351 +
1.352 +
1.353 +protected:
1.354 +
1.355 + CRawDisk(CFatMountCB& aOwner);
1.356 +
1.357 + //-- outlawed
1.358 + CRawDisk();
1.359 + CRawDisk(const CRawDisk&);
1.360 + CRawDisk& operator=(const CRawDisk&);
1.361 +
1.362 +
1.363 +protected:
1.364 +
1.365 + CFatMountCB* iFatMount; ///< Owning file system mount
1.366 +
1.367 +
1.368 +
1.369 + };
1.370 +
1.371 +class CFatFileCB;
1.372 +class RBitVector;
1.373 +
1.374 +/**
1.375 + A helper class. Holds the FAT volume parameters, which in turn are obtained from the Boot Sector
1.376 +*/
1.377 +class TFatVolParam
1.378 + {
1.379 +public:
1.380 +
1.381 + TFatVolParam();
1.382 + void Populate(const TFatBootSector& aBootSector);
1.383 + TBool operator==(const TFatVolParam& aRhs) const;
1.384 +
1.385 + //-- simple getters
1.386 + TUint32 ClusterSizeLog2() const {return iClusterSizeLog2; }
1.387 + TUint32 SectorSizeLog2() const {return iSectorSizeLog2; }
1.388 + TUint32 RootDirEnd() const {return iRootDirEnd; }
1.389 + TUint32 SectorsPerCluster() const {return iSectorsPerCluster; }
1.390 + TUint32 RootDirectorySector() const {return iRootDirectorySector;}
1.391 + TUint32 FirstFatSector() const {return iFirstFatSector; }
1.392 + TUint32 TotalSectors() const {return iTotalSectors; }
1.393 + TUint32 NumberOfFats() const {return iNumberOfFats; }
1.394 + TUint32 FatSizeInBytes() const {return iFatSizeInBytes; }
1.395 + TUint32 RootClusterNum() const {return iRootClusterNum; }
1.396 + TUint32 FSInfoSectorNum() const {return iFSInfoSectorNum; }
1.397 + TUint32 BkFSInfoSectorNum() const {return iBkFSInfoSectorNum; }
1.398 +
1.399 +protected:
1.400 + TUint32 iClusterSizeLog2; ///< Log2 of fat file system cluster size
1.401 + TUint32 iSectorSizeLog2; ///< Log2 of media sector size
1.402 + TUint32 iRootDirEnd; ///< End position of the root directory for Fat12/16
1.403 + TUint32 iSectorsPerCluster; ///< Sector per cluster ratio for mounted Fat file system volume
1.404 + TUint32 iRootDirectorySector; ///< Start sector of the root directory for Fat12/16
1.405 + TUint32 iFirstFatSector; ///< Start sector of the first Fat table in volume
1.406 + TUint32 iTotalSectors; ///< Total sectors on media partition
1.407 + TUint32 iNumberOfFats; ///< Number of Fats the volume has
1.408 + TUint32 iFatSizeInBytes; ///< Size of a single Fat table in volume
1.409 + TUint32 iRootClusterNum; ///< Cluster number for Root directory, for Fat32
1.410 + TUint32 iFSInfoSectorNum; ///< FSInfo Sector number. If 0, this means that corresponding value isn't set in BPB
1.411 + TUint32 iBkFSInfoSectorNum; ///< backup FSInfo Sector number
1.412 + };
1.413 +
1.414 +
1.415 +TBool IsLegalDosName(const TDesC& aName, TBool anAllowWildCards, TBool aUseExtendedChars, TBool aInScanDrive, TBool aAllowLowerCase, TBool aIsForFileCreation);
1.416 +TBool IsLegalDOSNameChar(TChar aCharacter, TBool aUseExtendedChars);
1.417 +
1.418 +TUint32 CalculatePageOffsetInCluster(TUint32 aPos, TUint aPageSzLog2);
1.419 +
1.420 +class CLruCache;
1.421 +class TLeafDirData;
1.422 +class CLeafDirCache;
1.423 +
1.424 +
1.425 +/**
1.426 +Fat file system mount implmentation, provides all that is required of a plug in
1.427 +file system mount as well as Fat mount specific functionality
1.428 +*/
1.429 +class CFatMountCB : public CLocDrvMountCB,
1.430 + public MFileSystemSubType,
1.431 + public MFileSystemClusterSize,
1.432 + public CMountCB::MFileAccessor,
1.433 + public CMountCB::MFileExtendedInterface
1.434 + {
1.435 +public:
1.436 + static CFatMountCB* NewL();
1.437 + ~CFatMountCB();
1.438 + void ConstructL();
1.439 +
1.440 +public:
1.441 +
1.442 + //-- overrides from the abstract CMountCB
1.443 + void MountL(TBool aForceMount);
1.444 + TInt ReMount();
1.445 + void Dismounted();
1.446 + void VolumeL(TVolumeInfo& aVolume) const;
1.447 + void SetVolumeL(TDes& aName);
1.448 + void MkDirL(const TDesC& aName);
1.449 + void RmDirL(const TDesC& aName);
1.450 + void DeleteL(const TDesC& aName);
1.451 + void RenameL(const TDesC& anOldName,const TDesC& anNewName);
1.452 + void ReplaceL(const TDesC& anOldName,const TDesC& anNewName);
1.453 + void EntryL(const TDesC& aName,TEntry& anEntry) const;
1.454 + void SetEntryL(const TDesC& aName,const TTime& aTime,TUint aMask,TUint aVal);
1.455 + void FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile);
1.456 + void DirOpenL(const TDesC& aName,CDirCB* aDir);
1.457 + void RawReadL(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt anOffset,const RMessagePtr2& aMessage) const;
1.458 + void RawWriteL(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt anOffset,const RMessagePtr2& aMessage);
1.459 + void GetShortNameL(const TDesC& aLongName,TDes& aShortName);
1.460 + void GetLongNameL(const TDesC& aShortName,TDes& aLongName);
1.461 + void ReadSectionL(const TDesC& aName,TInt aPos,TAny* aTrg,TInt aLength,const RMessagePtr2& aMessage);
1.462 + TInt CheckDisk();
1.463 + TInt ScanDrive();
1.464 + TInt ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2);
1.465 + TInt Lock(TMediaPassword& aOld,TMediaPassword& aNew,TBool aStore);
1.466 + TInt Unlock(TMediaPassword& aPassword,TBool aStore);
1.467 + TInt ClearPassword(TMediaPassword& aPassword);
1.468 + TInt ErasePassword();
1.469 + TInt ForceRemountDrive(const TDesC8* aMountInfo,TInt aMountInfoMessageHandle,TUint aFlags);
1.470 +
1.471 + void FinaliseMountL();
1.472 + void FinaliseMountL(TInt aOperation, TAny* aParam1=NULL, TAny* aParam2=NULL);
1.473 + TInt MountControl(TInt aLevel, TInt aOption, TAny* aParam);
1.474 + TTimeIntervalSeconds TimeOffset() const;
1.475 +
1.476 +protected:
1.477 +
1.478 + /** CFatMountCB states */
1.479 + enum TFatMntState
1.480 + {
1.481 + ENotMounted = 0, ///< 0, initial state, not mounted (mount state is inconsistent)
1.482 + EMounting, ///< 1, Mounting started (mount state is inconsistent)
1.483 + EInit_R, ///< 2, Initialised and not written (mount state is Consistent)
1.484 + EInit_W, ///< 3, Initialised and written (mount state is Consistent)
1.485 + EFinalised, ///< 4, Finalised (mount state is Consistent)
1.486 + EDismounted, ///< 5, Dismounted (mount state is inconsistent)
1.487 + EInit_Forced, ///< 6, forcedly mounted, special case (mount state is inconsistent)
1.488 + };
1.489 +
1.490 + inline TFatMntState State() const;
1.491 + inline void SetState(TFatMntState aState);
1.492 + TInt OpenMountForWrite();
1.493 + TInt IsFinalised(TBool& aFinalised);
1.494 +
1.495 + /**
1.496 + A wrapper around TDriveInterface providing its instantination and destruction.
1.497 + You must not create objects of this class, use DriveInterface() instead.
1.498 + */
1.499 + class XDriveInterface: public TDriveInterface
1.500 + {
1.501 + public:
1.502 + XDriveInterface() : TDriveInterface() {}
1.503 + ~XDriveInterface() {Close();}
1.504 + TBool Init(CFatMountCB* aMount) {return TDriveInterface::Init(aMount);}
1.505 + };
1.506 +
1.507 +
1.508 +public:
1.509 +
1.510 + enum TRenMode {EModeReplace,EModeRename};
1.511 +
1.512 + TBool ConsistentState() const;
1.513 + void CheckWritableL() const;
1.514 + void CheckStateConsistentL() const;
1.515 +
1.516 + inline TBool ReadOnly(void) const;
1.517 + inline void SetReadOnly(TBool aReadOnlyMode);
1.518 + inline TInt StartCluster(const TFatDirEntry & anEntry) const;
1.519 + inline CRawDisk& RawDisk() const;
1.520 + inline CFatFileSystem& FatFileSystem() const;
1.521 + inline CFatTable& FAT() const;
1.522 + inline TInt ClusterSizeLog2() const;
1.523 + inline TInt SectorSizeLog2() const;
1.524 + inline TInt TotalSectors() const;
1.525 + inline TInt SectorsPerCluster() const;
1.526 + inline TInt ClusterBasePosition() const;
1.527 + inline TInt RootDirectorySector() const;
1.528 + inline TUint RootDirEnd() const;
1.529 + inline TUint32 RootClusterNum() const;
1.530 +
1.531 + inline TFatType FatType() const;
1.532 + inline TBool Is16BitFat() const;
1.533 + inline TBool Is32BitFat() const;
1.534 +
1.535 + inline TUint32 MaxClusterNumber() const;
1.536 + inline TInt StartOfFatInBytes() const;
1.537 + inline TUint32 FirstFatSector() const;
1.538 +
1.539 + inline TInt NumberOfFats() const;
1.540 + inline TInt FatSizeInBytes() const;
1.541 + inline TInt ClusterRelativePos(TInt aPos) const;
1.542 + inline TUint StartOfRootDirInBytes() const;
1.543 + inline TUint32 UsableClusters() const;
1.544 + inline TBool IsBadCluster(TInt aCluster) const;
1.545 + inline TBool IsRuggedFSys() const;
1.546 + inline void SetRuggedFSys(TBool aVal);
1.547 +
1.548 + inline TInt RootIndicator() const;
1.549 +
1.550 + inline TBool IsRootDir(const TEntryPos &aEntry) const;
1.551 + inline CAsyncNotifier* Notifier() const;
1.552 + inline TDriveInterface& DriveInterface() const;
1.553 +
1.554 + inline TBool IsEndOfClusterCh(TInt aCluster) const;
1.555 + inline void SetEndOfClusterCh(TInt &aCluster) const;
1.556 +
1.557 +
1.558 + void ReadUidL(TInt aCluster,TEntry& anEntry) const;
1.559 +
1.560 + void ReadDirEntryL(const TEntryPos& aPos,TFatDirEntry& aDirEntry) const;
1.561 + void WriteDirEntryL(const TEntryPos& aPos,const TFatDirEntry& aDirEntry);
1.562 +
1.563 + void DirReadL(const TEntryPos& aPos,TInt aLength,TDes8& aDes) const;
1.564 + void DirWriteL(const TEntryPos& aPos,const TDesC8& aDes);
1.565 +
1.566 + void ReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
1.567 + void WriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TInt& aBadcluster, TInt &aGoodcluster);
1.568 + void MoveToNextEntryL(TEntryPos& aPos) const;
1.569 + void MoveToDosEntryL(TEntryPos& aPos,TFatDirEntry& anEntry) const;
1.570 + void EnlargeL(TInt aSize);
1.571 + void ReduceSizeL(TInt aPos,TInt aLength);
1.572 + void DoDismount();
1.573 + TBool ProcessFSInfoSectors(CFatTable::TMountParams& aFatInitParams) const;
1.574 +
1.575 +
1.576 + void DoRenameOrReplaceL(const TDesC& anOldName,const TDesC& aNewName,TRenMode aMode,TEntryPos& aNewPos);
1.577 + void FindDosNameL(const TDesC& aName,TUint anAtt,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError) const;
1.578 +
1.579 + void Dismount();
1.580 +
1.581 + void InitializeRootEntry(TFatDirEntry & anEntry) const;
1.582 +
1.583 + TInt64 MakeLinAddrL(const TEntryPos& aPos) const;
1.584 +
1.585 + inline const TFatConfig& FatConfig() const;
1.586 + TBool CheckVolumeTheSame();
1.587 +
1.588 + void InvalidateLeafDirCache();
1.589 +
1.590 + void BlockMapReadFromClusterListL(TEntryPos& aPos, TInt aLength, SBlockMapInfo& aInfo);
1.591 + virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
1.592 + virtual TInt GetFileUniqueId(const TDesC& aName, TInt64& aUniqueId);
1.593 + virtual TInt Spare3(TInt aVal, TAny* aPtr1, TAny* aPtr2);
1.594 + virtual TInt Spare2(TInt aVal, TAny* aPtr1, TAny* aPtr2);
1.595 + virtual TInt Spare1(TInt aVal, TAny* aPtr1, TAny* aPtr2);
1.596 +
1.597 +public:
1.598 +
1.599 + // interface extension implementation
1.600 + virtual TInt SubType(TDes& aName) const;
1.601 + virtual TInt ClusterSize() const;
1.602 + virtual void ReadSection64L(const TDesC& aName, TInt64 aPos, TAny* aTrg, TInt aLength, const RMessagePtr2& aMessage);
1.603 +
1.604 +private:
1.605 +
1.606 + /** An ad hoc internal helper object for using in DoFindL() method and its derivatives */
1.607 + class TFindHelper
1.608 + {
1.609 + public:
1.610 + TFindHelper() {isInitialised = EFalse;}
1.611 + void InitialiseL(const TDesC& aTargetName);
1.612 + TBool MatchDosEntryName(const TUint8* apDosEntryName) const;
1.613 + TBool TrgtNameIsLegalDos() const {ASSERT (isInitialised) ;return isLegalDosName;}
1.614 +
1.615 + private:
1.616 + TFindHelper(const TFindHelper&);
1.617 + TFindHelper& operator=(const TFindHelper&);
1.618 + public:
1.619 + TPtrC iTargetName; ///< pointer to the aTargetName, used in DoRummageDirCacheL() as a parameter
1.620 + private:
1.621 + TBool isInitialised :1; ///< ETrue if the object is initialised. It can be done only once.
1.622 + TBool isLegalDosName :1; ///< ETrue if iTargetName is a legal DOS name
1.623 + TShortName iShortName; ///< a short DOS name in XXXXXXXXYYY format generated from aTargetName
1.624 + };
1.625 +
1.626 +
1.627 + /**
1.628 + An ad hoc internal helper object for entry creations
1.629 + */
1.630 + class XFileCreationHelper
1.631 + {
1.632 + public:
1.633 + XFileCreationHelper();
1.634 + ~XFileCreationHelper();
1.635 + void Close();
1.636 + void InitialiseL(const TDesC& aTargetName);
1.637 + TInt GetValidatedShortName(TShortName& aShortName) const;
1.638 + void CheckShortNameCandidates(const TUint8* apDosEntryName);
1.639 +
1.640 + // inline functions for sets and gets
1.641 + // note all the get functions have been checked against initialisation status
1.642 + inline TBool IsInitialised() const;
1.643 + inline TUint16 NumOfAddingEntries() const;
1.644 + inline TEntryPos EntryAddingPos()const;
1.645 + inline TBool IsNewEntryPosFound() const;
1.646 + inline TBool IsTrgNameLegalDosName() const;
1.647 +
1.648 + inline void SetEntryAddingPos(const TEntryPos& aEntryPos);
1.649 + inline void SetIsNewEntryPosFound(TBool aFound);
1.650 +
1.651 + private:
1.652 + XFileCreationHelper(const XFileCreationHelper&);
1.653 + XFileCreationHelper& operator=(const TFindHelper&);
1.654 +
1.655 + private:
1.656 + TPtrC iTargetName; ///< pointer to hold the long file name of the target file
1.657 + TUint16 iNumOfAddingEntries;///< calculated number of entries to add
1.658 + TEntryPos iEntryAddingPos; ///< contains new entry position for adding if found any
1.659 + TBool isNewEntryPosFound; ///< flags whether the position for new entries is found
1.660 + TBool isInitialised :1; ///< flags whether the object is initialised
1.661 + TBool isTrgNameLegalDosName :1; ///< flags whether the target file name is a valid Dos name
1.662 + /**
1.663 + an array that holds short name candidates, prepared on initialisation.
1.664 + */
1.665 + RArray<TShortName> iShortNameCandidates;
1.666 + };
1.667 +
1.668 +
1.669 +
1.670 + TBool DoRummageDirCacheL(TUint anAtt,TEntryPos& aStartEntryPos,TFatDirEntry& aStartEntry,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName, const TFindHelper& aAuxParam, XFileCreationHelper* aFileCreationHelper, const TLeafDirData& aLeafDir) const;
1.671 + TBool DoFindL(const TDesC& aName,TUint anAtt,TEntryPos& aStartEntryPos,TFatDirEntry& aStartEntry,TEntryPos& aDosEntryPos,TFatDirEntry& aDosEntry,TDes& aFileName,TInt anError, XFileCreationHelper* aFileCreationHelper, const TLeafDirData& aLeafDirData) const;
1.672 + void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos, XFileCreationHelper* aFileCreationHelper) const;
1.673 +
1.674 + void FindEntryStartL(const TDesC& aName,TUint anAtt,TFatDirEntry& anEntry,TEntryPos& aPos) const;
1.675 +
1.676 + void CheckFatForLoopsL(const TFatDirEntry& anEntry) const;
1.677 + void DoCheckFatForLoopsL(TInt aCluster,TInt& aPreviousCluster,TInt& aChangePreviousCluster,TInt& aCount) const;
1.678 + void InitializeL(const TLocalDriveCaps& aLocDrvCaps, TBool aIgnoreFSInfo=EFalse);
1.679 + void DoReadFromClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aTrg,const RMessagePtr2& aMessage,TInt anOffset) const;
1.680 + void DoWriteToClusterListL(TEntryPos& aPos,TInt aLength,const TAny* aSrc,const RMessagePtr2& aMessage,TInt anOffset, TInt aLastcluster, TInt& aBadcluster, TInt& aGoodcluster);
1.681 + TBool IsUniqueNameL(const TShortName& aName,TInt aDirCluster);
1.682 + TBool FindShortNameL(const TShortName& aName,TEntryPos& anEntryPos);
1.683 + void ReplaceClashingNameL(const TShortName& aNewName,const TEntryPos& anEntryPos);
1.684 + TBool GenerateShortNameL(TInt aDirCluster,const TDesC& aLongName,TShortName& aShortName, TBool aForceRandomize=EFalse);
1.685 + TInt FindLeafDirL(const TDesC& aName, TLeafDirData& aLeafDir) const;
1.686 +
1.687 + TInt GetDirEntry(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
1.688 + TBool DoGetDirEntryL(TEntryPos& aPos,TFatDirEntry& aDosEntry,TFatDirEntry& aStartEntry,TDes& aLongFileName) const;
1.689 +
1.690 + void WriteDirEntryL(TEntryPos& aPos,const TFatDirEntry& aFatDirEntry,const TDesC& aLongFileName);
1.691 + void EraseDirEntryL(TEntryPos aPos,const TFatDirEntry& anEntry);
1.692 + void EraseDirEntryL(const TEntryPos& aPos);
1.693 + void InitializeFirstDirClusterL(TInt aCluster,TInt aParentCluster);
1.694 + void AddDirEntryL(TEntryPos& aPos,TInt aNameLength);
1.695 + void ZeroDirClusterL(TInt aCluster);
1.696 +
1.697 + TInt DoWriteBootSector(TInt64 aMediaPos, const TFatBootSector& aBootSector) const;
1.698 + TInt DoReadBootSector(TInt64 aMediaPos, TFatBootSector& aBootSector) const;
1.699 + TInt ReadBootSector(TFatBootSector& aBootSector, TBool aDoNotReadBkBootSec=EFalse);
1.700 +
1.701 + TInt WriteFSInfoSector(TInt64 aMediaPos, const TFSInfo& aFSInfo) const;
1.702 + TInt ReadFSInfoSector(TInt64 aMediaPos, TFSInfo& aFSInfo) const;
1.703 +
1.704 + TBool IsDirectoryEmptyL(TInt aCluster);
1.705 + void ExtendClusterListZeroedL(TInt aNumber,TInt& aCluster);
1.706 + void WritePasswordData();
1.707 +
1.708 + void WriteVolumeLabelL(const TDesC8& aVolumeLabel) const;
1.709 + TInt ReadVolumeLabelFile(TDes8& aLabel);
1.710 + void WriteVolumeLabelFileL(const TDesC8& aNewName);
1.711 + void FindVolumeLabelFileL(TDes8& aLabel, TEntryPos& aDosEntryPos, TFatDirEntry& aDosEntry);
1.712 + void GetVolumeLabelFromDiskL(const TFatBootSector& aBootSector);
1.713 + void TrimVolumeLabel(TDes8& aLabel) const;
1.714 +
1.715 + TInt DoRunScanDrive();
1.716 + TBool VolumeCleanL();
1.717 + void SetVolumeCleanL(TBool aClean);
1.718 + TBool VolCleanFlagSupported() const;
1.719 +
1.720 + void DoUpdateFSInfoSectorsL(TBool aInvalidateFSInfo);
1.721 + void UnFinaliseMountL();
1.722 + void DoReMountL();
1.723 + void SetFatType(TFatType aFatType);
1.724 +
1.725 +
1.726 +private:
1.727 +
1.728 +
1.729 + CFatMountCB();
1.730 +
1.731 + TInt GetDosEntryFromNameL(const TDesC& aName, TEntryPos& aDosEntryPos, TFatDirEntry& aDosEntry);
1.732 +
1.733 + TInt MntCtl_DoCheckFileSystemMountable();
1.734 +
1.735 +
1.736 +private:
1.737 +
1.738 + TBool iReadOnly : 1;///< if true, the drive is in read-only mode
1.739 + TBool iRamDrive : 1;///< true if this is a RAM drive
1.740 + TBool iMainBootSecValid : 1;///< true if the main boot sector is valid, if false, a backup boot sector may be in use.
1.741 +
1.742 + TFatMntState iState; ///< this mounnt internal state
1.743 +
1.744 + TFatType iFatType; ///< FAT type, FAT12,16 or 32
1.745 + TUint32 iFatEocCode; ///< End Of Cluster Chain code, 0xff8 for FAT12, 0xfff8 for FAT16, and 0xffffff8 for FAT32
1.746 +
1.747 + CLeafDirCache* iLeafDirCache; ///< A cache for most recently visited directories, only valid when limit is set bigger than 1
1.748 + HBufC* iLastLeafDir; ///< The last visited directory, only valid when limit of iLeafDirCache is less than 1
1.749 + TInt iLastLeafDirCluster; ///< Cluster number of the last visited cluster, only valid when limit of iLeafDirCache is less than 1
1.750 +
1.751 + TFatVolParam iVolParam; ///< FAT volume parameters, populated form the boot sector values.
1.752 +
1.753 + TInt iFirstFreeByte; ///< First free byte in media (start of the data area on the volume)
1.754 + TUint32 iUsableClusters; ///< Number of usable cluster on the volume
1.755 +
1.756 + CFatTable* iFatTable; ///< Pointer to the volume Fat
1.757 + CRawDisk* iRawDisk; ///< Pointer to the raw data interface class
1.758 +
1.759 + CAsyncNotifier* iNotifier; ///< Async notifier for notifying user of Fat error conditions
1.760 +
1.761 + XDriveInterface iDriverInterface; ///< the object representing interface to the drive, provides read/write access and notifiers
1.762 + TInt iChkDiscRecLevel; ///< Check disk recursion level counter. A temporary measure.
1.763 + TFatConfig iFatConfig; ///< FAT parametrers from estart.txt
1.764 +
1.765 + XFileCreationHelper iFileCreationHelper;
1.766 +
1.767 +
1.768 +#ifdef _DEBUG
1.769 + private:
1.770 + //-- debug odds and ends
1.771 + inline TBool IsWriteFail()const;
1.772 + inline void SetWriteFail(TBool aIsWriteFail);
1.773 + inline TInt WriteFailCount()const;
1.774 + inline void SetWriteFailCount(TInt aFailCount);
1.775 + inline void DecWriteFailCount();
1.776 + inline TInt WriteFailError()const;
1.777 + inline void SetWriteFailError(TInt aErrorValue);
1.778 +
1.779 +
1.780 + TBool iIsWriteFail : 1; ///< Flag to indicate if write failed used for debugging
1.781 + TBool iCBRecFlag : 1; ///< in debug mode used for checking unwanted recursion
1.782 +
1.783 + TInt iWriteFailCount; ///< Write fail count for debug
1.784 + TInt iWriteFailError; ///< Write fail error to use for debug
1.785 +
1.786 +#endif
1.787 +
1.788 +friend class CFatFormatCB;
1.789 +friend class CScanDrive;
1.790 +friend class TDriveInterface;
1.791 + };
1.792 +
1.793 +
1.794 +
1.795 +
1.796 +/**
1.797 +Fat file system file subsession implmentation, provides all that is required of a plug in
1.798 +file system file as well as Fat specific functionality
1.799 +*/
1.800 +class CFatFileCB : public CFileCB, public CFileCB::MBlockMapInterface, public CFileCB::MExtendedFileInterface
1.801 + {
1.802 +public:
1.803 + CFatFileCB();
1.804 + ~CFatFileCB();
1.805 +public:
1.806 + void RenameL(const TDesC& aNewName);
1.807 + void ReadL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
1.808 + void WriteL(TInt aPos,TInt& aLength,const TAny* aDes,const RMessagePtr2& aMessage);
1.809 + void SetSizeL(TInt aSize);
1.810 + void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal);
1.811 + void FlushDataL();
1.812 + void FlushAllL();
1.813 +public:
1.814 + void CheckPosL(TUint aPos);
1.815 + void SetL(const TFatDirEntry& aFatDirEntry,TShare aShare,const TEntryPos& aPos);
1.816 + void CreateSeekIndex();
1.817 +
1.818 + inline TBool IsSeekIndex() const;
1.819 +
1.820 + // from MBlockMapInterface
1.821 + TInt BlockMap(SBlockMapInfo& aInfo, TInt64& aStartPos, TInt64 aEndPos);
1.822 +
1.823 + // from CFileCB
1.824 + virtual TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
1.825 +
1.826 + // from CFileCB::MExtendedFileInterface
1.827 + virtual void ReadL(TInt64 aPos,TInt& aLength,TDes8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
1.828 + virtual void WriteL(TInt64 aPos,TInt& aLength,const TDesC8* aDes,const RMessagePtr2& aMessage, TInt aOffset);
1.829 + virtual void SetSizeL(TInt64 aSize);
1.830 +
1.831 +private:
1.832 + inline CFatMountCB& FatMount() const;
1.833 + inline CFatTable& FAT();
1.834 + inline TInt ClusterSizeLog2();
1.835 + inline TInt ClusterRelativePos(TInt aPos);
1.836 +
1.837 +
1.838 + void FlushStartClusterL();
1.839 + TInt SeekToPosition(TInt aNewCluster,TInt aClusterOffset);
1.840 + void SetSeekIndexValueL(TInt aFileCluster,TInt aStoredCluster);
1.841 + void ResizeIndex(TInt aNewMult,TUint aNewSize);
1.842 + TInt CalcSeekIndexSize(TUint aSize);
1.843 + TBool IsSeekBackwards(TUint aPos);
1.844 + void ClearIndex(TUint aNewSize);
1.845 + void DoSetSizeL(TUint aSize,TBool aIsSizeWrite);
1.846 + void WriteFileSizeL(TUint aSize);
1.847 +
1.848 +private:
1.849 +
1.850 + TUint32* iSeekIndex; ///< Seek index into file
1.851 + TInt iSeekIndexSize; ///< size of seek index
1.852 + TInt iStartCluster; ///< Start cluster number of file
1.853 + TEntryPos iCurrentPos; ///< Current position in file data
1.854 + TEntryPos iFileDirPos; ///< File directory entry position
1.855 + TBool iFileSizeModified;
1.856 + };
1.857 +
1.858 +
1.859 +/**
1.860 +Fat file system directory subsession implmentation, provides all that is required of a plug in
1.861 +file system directory as well as Fat specific functionality
1.862 +*/
1.863 +class CFatDirCB : public CDirCB
1.864 + {
1.865 +public:
1.866 + static CFatDirCB* NewL();
1.867 + ~CFatDirCB();
1.868 +public:
1.869 + void ReadL(TEntry& anEntry);
1.870 + void StoreLongEntryNameL(const TDesC& aName);
1.871 +public:
1.872 + void SetDirL(const TFatDirEntry& anEntry,const TDesC& aMatchName);
1.873 + inline CFatMountCB& FatMount();
1.874 +private:
1.875 + CFatDirCB();
1.876 +private:
1.877 + TFatDirEntry iEntry; ///< Current directory entry in this directory
1.878 + TEntryPos iCurrentPos; ///< Current position in directory
1.879 + HBufC* iMatch; ///< Current name being searched in directory (Dos Name)
1.880 + HBufC* iLongNameBuf; ///< Long name storage
1.881 + TBool iMatchUid; ///< Flag to indicate if UID matches
1.882 + };
1.883 +
1.884 +/**
1.885 + Fat file system Format subsession implmentation, provides all that is required of a plug in
1.886 + file system format as well as Fat specific functionality
1.887 +*/
1.888 +class CFatFormatCB : public CFormatCB
1.889 + {
1.890 +public:
1.891 + CFatFormatCB();
1.892 + ~CFatFormatCB();
1.893 +public:
1.894 +
1.895 + //-- overrides from CFormatCB
1.896 + void DoFormatStepL();
1.897 +
1.898 +private:
1.899 + //-- overrides from CFormatCB
1.900 + TInt GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput);
1.901 +
1.902 +private:
1.903 +
1.904 + TInt DoProcessTVolFormatParam(const TVolFormatParam_FAT* apVolFormatParam);
1.905 +
1.906 + void CreateBootSectorL();
1.907 + void CreateFSInfoSectorL();
1.908 + void CreateReservedBootSectorL();
1.909 + void InitializeFormatDataL();
1.910 + void DoZeroFillMediaL(TInt64 aStartPos, TInt64 aEndPos);
1.911 +
1.912 + TInt InitFormatDataForVariableSizeDisk(TInt aDiskSizeInSectors);
1.913 + TInt InitFormatDataForFixedSizeDiskNormal(TInt aDiskSizeInSectors, const TLocalDriveCapsV6& aCaps);
1.914 + TInt InitFormatDataForFixedSizeDiskCustom(const TLDFormatInfo& aFormatInfo);
1.915 + TInt InitFormatDataForFixedSizeDiskUser(TInt aDiskSizeInSectors);
1.916 + void AdjustClusterSize(TInt aRecommendedSectorsPerCluster);
1.917 + TInt AdjustFirstDataSectorAlignment(TInt aBlockSize);
1.918 + TInt FirstDataSector() const;
1.919 +
1.920 + TInt HandleCorrupt(TInt aError);
1.921 + TInt BadSectorToCluster();
1.922 + void TranslateL();
1.923 + TInt DoTranslate(TPtr8& aBuf, RArray<TInt>& aArray);
1.924 + void RecordOldInfoL();
1.925 + TInt MaxFat12Sectors() const;
1.926 + TInt MaxFat16Sectors() const;
1.927 + TUint32 MaxFat32Sectors() const;
1.928 + inline TBool Is16BitFat() const;
1.929 + inline TBool Is32BitFat() const;
1.930 + inline CFatMountCB& FatMount();
1.931 + inline CProxyDrive* LocalDrive();
1.932 + TFatType SuggestFatType() const;
1.933 +
1.934 +private:
1.935 +
1.936 + TBool iVariableSize; ///< Flag to indicat if we are dealing with a variable size volume
1.937 + TInt iBytesPerSector; ///< Byte per sector of media
1.938 + TInt iSectorSizeLog2; ///< Sector size in log2
1.939 + TInt iNumberOfFats; ///< Number of Fats the volume will contain
1.940 + TInt iReservedSectors; ///< Number of reserved sectors in the volume
1.941 + TInt iRootDirEntries; ///< Nummer of root directory entries the root dir will have, specific to Fat12/16 volumes
1.942 + TInt iSectorsPerCluster; ///< Sector per cluster ration the volume will be formatted with
1.943 + TInt iSectorsPerFat; ///< Number of sectors the Fat uses
1.944 + TInt iMaxDiskSectors; ///< number of sectors the volume has
1.945 + TFormatInfo iFormatInfo; ///< format information for a custom format
1.946 + TBuf8<16> iFileSystemName;///< Buffer to contain the volume name
1.947 + TInt iHiddenSectors; ///< Number of hidden sectors in the volume
1.948 + TInt iNumberOfHeads; ///< Number of heads the media device has, not used so far as only used on solid state media.
1.949 + TInt iSectorsPerTrack; ///< Number of sectors the media device has, not used so far as only used on solid state media.
1.950 + TUint32 iRootClusterNum; ///< cluster number used for root directory, Fat32 specific
1.951 + TUint32 iCountOfClusters; ///< Count of clusters on the media
1.952 + RArray<TInt> iBadClusters; ///< Array of bad cluster numbers
1.953 + RArray<TInt> iBadSectors; ///< Array of bad sector numbers
1.954 + TBool iDiskCorrupt; ///< Disk is corrupt when format or not
1.955 + TInt iOldFirstFreeSector;
1.956 + TInt iOldSectorsPerCluster;
1.957 + };
1.958 +
1.959 +/**
1.960 +Required file system class used by file server to create the file system objects
1.961 +*/
1.962 +class CFatFileSystem : public CFileSystem
1.963 + {
1.964 +public:
1.965 + static CFatFileSystem* New();
1.966 + ~CFatFileSystem();
1.967 +public:
1.968 + TInt Install();
1.969 + CMountCB* NewMountL() const;
1.970 + CFileCB* NewFileL() const;
1.971 + CDirCB* NewDirL() const;
1.972 + CFormatCB* NewFormatL() const;
1.973 + TInt DefaultPath(TDes& aPath) const;
1.974 + TBool IsExtensionSupported() const;
1.975 + TBool GetUseLocalTime() const;
1.976 + void SetUseLocalTime(TBool aFlag);
1.977 + TInt GetInterface(TInt aInterfaceId, TAny*& aInterface,TAny* aInput);
1.978 +protected:
1.979 + CFatFileSystem();
1.980 + /**
1.981 + If true, then local time will be used when writing timestamps to FS. When reading,
1.982 + timestamps will be assumed local and converted back to UTC.
1.983 + At present, this behaviour will also be conditional upon a particular drive being logically removable.
1.984 + */
1.985 + TBool iUseLocalTimeIfRemovable;
1.986 + };
1.987 +
1.988 +
1.989 +
1.990 +/**
1.991 +Locale utilities allows the file system to call into a specific locale for tasks
1.992 +such as Dos name to unicode conversions and testing the legality of characters for
1.993 +any given locale.
1.994 +*/
1.995 +class LocaleUtils
1.996 +
1.997 + {
1.998 +public:
1.999 + static void ConvertFromUnicodeL(TDes8& aForeign, const TDesC16& aUnicode, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate);
1.1000 + static void ConvertToUnicodeL(TDes16& aUnicode, const TDesC8& aForeign, TFatUtilityFunctions::TOverflowAction aOverflowAction=TFatUtilityFunctions::EOverflowActionTruncate);
1.1001 + static TBool IsLegalShortNameCharacter(TUint aCharacter,TBool aUseExtendedChars=EFalse);
1.1002 + };
1.1003 +//
1.1004 +
1.1005 +/**
1.1006 +Converts Dos time (from a directory entry) to TTime format
1.1007 +
1.1008 +@param aDosTime Dos format time
1.1009 +@param aDosDate Dos format Date
1.1010 +@return TTime format of Dos time passed in
1.1011 +*/
1.1012 +TTime DosTimeToTTime(TInt aDosTime,TInt aDosDate);
1.1013 +/**
1.1014 +Converts TTime format to Dos time format
1.1015 +
1.1016 +@param aTime TTime to convert to Dos time
1.1017 +@return Dos time format
1.1018 +*/
1.1019 +TInt DosTimeFromTTime(const TTime& aTime);
1.1020 +/**
1.1021 +Converts TTime format to Dos time format
1.1022 +
1.1023 +@param aTime TTime to convert to Dos Date
1.1024 +@return Dos Date format
1.1025 +*/
1.1026 +TInt DosDateFromTTime(const TTime& aTime);
1.1027 +/**
1.1028 +Converts Dos Directory entry format to 8.3 format
1.1029 +
1.1030 +@param aDosName Directory entry format with space delimeter
1.1031 +@return 8.3 Dos filename format
1.1032 +*/
1.1033 +TBuf8<12> DosNameToStdFormat(const TDesC8& aDosName);
1.1034 +/**
1.1035 +Converts 8.3 format to Dos Directory entry format
1.1036 +
1.1037 +@param aStdFormatName 8.3 Dos filename format
1.1038 +@return Directory entry format with space delimeter
1.1039 +*/
1.1040 +TBuf8<12> DosNameFromStdFormat(const TDesC8& aStdFormatName);
1.1041 +/**
1.1042 +Fault function calls user panic with a fault reason
1.1043 +
1.1044 +@param Enumerated fault reason
1.1045 +*/
1.1046 +void Fault(TFault aFault);
1.1047 +/**
1.1048 +calculates the number of VFat directory entries for a given file/directory name length
1.1049 +
1.1050 +@param the length in characters of the name
1.1051 +@return the number of VFat entries required
1.1052 +*/
1.1053 +TInt NumberOfVFatEntries(TInt aNameLength);
1.1054 +/**
1.1055 +Calculates the check sum for a standard directory entry
1.1056 +
1.1057 +@param the Dos name for the directory entry
1.1058 +@return the checksum
1.1059 +*/
1.1060 +TUint8 CalculateShortNameCheckSum(const TDesC8& aShortName);
1.1061 +
1.1062 +TUint32 EocCodeByFatType(TFatType aFatType);
1.1063 +
1.1064 +
1.1065 +#include "sl_std.inl"
1.1066 +#include "sl_bpb.inl"
1.1067 +#include "fat_dir_entry.inl"
1.1068 +
1.1069 +#endif //SL_STD_H