--- a/userlibandfileserver/fileserver/sfat/sl_fmt.cpp Mon Oct 19 15:55:17 2009 +0100
+++ b/userlibandfileserver/fileserver/sfat/sl_fmt.cpp Mon Dec 21 16:14:42 2009 +0000
@@ -15,6 +15,14 @@
//
//
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!
+//!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
+//!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
#include "sl_std.h"
#include <e32hal.h>
@@ -26,51 +34,51 @@
// arbitrary limit upon the WINS ramdisk.
//
static TInt64 GetRamDiskSizeInBytes()
- {
+ {
#if defined(__EPOC32__)
- TMemoryInfoV1Buf memInfo;
- UserHal::MemoryInfo(memInfo);
- TUint max = memInfo().iTotalRamInBytes; // not really the correct max
- return max;
+ TMemoryInfoV1Buf memInfo;
+ UserHal::MemoryInfo(memInfo);
+ TUint max = memInfo().iTotalRamInBytes; // not really the correct max
+ return max;
#else
const TInt KArbitraryWinsRamDiskSize=0x400000; //-- Default size for a Ram drive, 4MB
- return(KArbitraryWinsRamDiskSize);
+ return(KArbitraryWinsRamDiskSize);
#endif
- }
+ }
CFatFormatCB::CFatFormatCB()
- {
- __PRINT1(_L("CFatFormatCB::CFatFormatCB() [%x]"),this);
+ {
+ __PRINT1(_L("CFatFormatCB::CFatFormatCB() [%x]"),this);
}
CFatFormatCB::~CFatFormatCB()
- {
- __PRINT1(_L("CFatFormatCB::~CFatFormatCB() [%x]"),this);
+ {
+ __PRINT1(_L("CFatFormatCB::~CFatFormatCB() [%x]"),this);
iBadSectors.Close();
- iBadClusters.Close();
- }
+ iBadClusters.Close();
+ }
TInt CFatFormatCB::MaxFat16Sectors() const
//
// Calculate the size of a 16 bit FAT
//
- {
-
- TInt fatSizeInBytes=(2*iMaxDiskSectors)/iSectorsPerCluster+(iBytesPerSector-1);
- return(fatSizeInBytes/iBytesPerSector);
- }
+ {
+
+ TInt fatSizeInBytes=(2*iMaxDiskSectors)/iSectorsPerCluster+(iBytesPerSector-1);
+ return(fatSizeInBytes/iBytesPerSector);
+ }
TInt CFatFormatCB::MaxFat12Sectors() const
//
// Calculate the size of a 12 bit FAT
//
- {
-
- TInt maxDiskClusters=iMaxDiskSectors/iSectorsPerCluster;
- TInt fatSizeInBytes=maxDiskClusters+(maxDiskClusters>>1)+(iBytesPerSector-1);
- return(fatSizeInBytes/iBytesPerSector);
- }
+ {
+
+ TInt maxDiskClusters=iMaxDiskSectors/iSectorsPerCluster;
+ TInt fatSizeInBytes=maxDiskClusters+(maxDiskClusters>>1)+(iBytesPerSector-1);
+ return(fatSizeInBytes/iBytesPerSector);
+ }
//-------------------------------------------------------------------------------------------------------------------
/**
@@ -113,12 +121,12 @@
//-------------------------------------------------------------------------------------------------------------------
static TInt DiskSizeInSectorsL(TInt64 aSizeInBytes)
- {
+ {
const TInt64 totalSectors64=aSizeInBytes>>KDefSectorSzLog2;
- const TInt totalSectors32=I64LOW(totalSectors64);
+ const TInt totalSectors32=I64LOW(totalSectors64);
__PRINT2(_L("Disk size:%LU, max disk sectors:%d"),aSizeInBytes, totalSectors32);
return totalSectors32;
- }
+ }
/**
@@ -144,60 +152,60 @@
Initialize format data.
*/
void CFatFormatCB::InitializeFormatDataL()
- {
+ {
- __PRINT1(_L("CFatFormatCB::InitializeFormatDataL() drv:%d"), Drive().DriveNumber());
- TLocalDriveCapsV6Buf caps;
- User::LeaveIfError(LocalDrive()->Caps(caps));
- iVariableSize=((caps().iMediaAtt)&KMediaAttVariableSize) ? (TBool)ETrue : (TBool)EFalse;
+ __PRINT1(_L("CFatFormatCB::InitializeFormatDataL() drv:%d"), Drive().DriveNumber());
+ TLocalDriveCapsV6Buf caps;
+ User::LeaveIfError(LocalDrive()->Caps(caps));
+ iVariableSize=((caps().iMediaAtt)&KMediaAttVariableSize) ? (TBool)ETrue : (TBool)EFalse;
- iBytesPerSector=KDefaultSectorSize;
- iSectorSizeLog2 = Log2(iBytesPerSector);
- iHiddenSectors=caps().iHiddenSectors;
- iNumberOfHeads=2;
- iSectorsPerTrack=16;
-
+ iBytesPerSector=KDefaultSectorSize;
+ iSectorSizeLog2 = Log2(iBytesPerSector);
+ iHiddenSectors=caps().iHiddenSectors;
+ iNumberOfHeads=2;
+ iSectorsPerTrack=16;
+
if (iVariableSize)
- {// Variable size implies ram disk
- iMaxDiskSectors=DiskSizeInSectorsL(GetRamDiskSizeInBytes());
- InitFormatDataForVariableSizeDisk(iMaxDiskSectors);
- }
- else
- {//-- fixed-size media
+ {// Variable size implies ram disk
+ iMaxDiskSectors=DiskSizeInSectorsL(GetRamDiskSizeInBytes());
+ InitFormatDataForVariableSizeDisk(iMaxDiskSectors);
+ }
+ else
+ {//-- fixed-size media
iMaxDiskSectors=DiskSizeInSectorsL(caps().iSize);
-
+
__PRINT3(_L("::InitializeFormatDataL() iMode:0x%x, ilen:%d, extrai:%d"), iMode, iSpecialInfo.Length(), caps().iExtraInfo);
if(iMode & ESpecialFormat)
- {
- if(iSpecialInfo.Length())
- {
+ {
+ if(iSpecialInfo.Length())
+ {
if (caps().iExtraInfo) // conflict between user and media
User::Leave(KErrNotSupported);
- else // User-specified
+ else // User-specified
User::LeaveIfError(InitFormatDataForFixedSizeDiskUser(iMaxDiskSectors));
}
- else
- {
+ else
+ {
if (caps().iExtraInfo)
User::LeaveIfError(InitFormatDataForFixedSizeDiskCustom(caps().iFormatInfo));
else
- User::LeaveIfError(InitFormatDataForFixedSizeDiskNormal(iMaxDiskSectors, caps()));
+ User::LeaveIfError(InitFormatDataForFixedSizeDiskNormal(iMaxDiskSectors, caps()));
}
- }
+ }
else //if(iMode & ESpecialFormat)
{
// Normal format with default values
// - Media with special format requirements will always use them
// even without the ESpecialFormat option.
if(caps().iExtraInfo)
- User::LeaveIfError(InitFormatDataForFixedSizeDiskCustom(caps().iFormatInfo));
+ User::LeaveIfError(InitFormatDataForFixedSizeDiskCustom(caps().iFormatInfo));
else
- User::LeaveIfError(InitFormatDataForFixedSizeDiskNormal(iMaxDiskSectors, caps()));
- }
+ User::LeaveIfError(InitFormatDataForFixedSizeDiskNormal(iMaxDiskSectors, caps()));
+ }
} //else(iVariableSize)
- }
+ }
/**
Initialize the format parameters for a variable sized disk
@@ -206,21 +214,21 @@
@return standard error code
*/
TInt CFatFormatCB::InitFormatDataForVariableSizeDisk(TInt aDiskSizeInSectors)
- {
- iNumberOfFats=2; // 1 FAT 1 Indirection table (FIT)
- iReservedSectors=1;
- iRootDirEntries=2*(4*KDefaultSectorSize)/sizeof(SFatDirEntry);
- TInt minSectorsPerCluster=(aDiskSizeInSectors+KMaxFAT16Entries-1)/KMaxFAT16Entries;
- iSectorsPerCluster=1;
- while (minSectorsPerCluster>iSectorsPerCluster)
- iSectorsPerCluster<<=1;
- __PRINT1(_L("iSectorsPerCluster = %d"),iSectorsPerCluster);
- iSectorsPerFat=MaxFat16Sectors();
- __PRINT1(_L("iSectorsPerFat = %d"),iSectorsPerFat);
- iFileSystemName=KFileSystemName16;
+ {
+ iNumberOfFats=2; // 1 FAT 1 Indirection table (FIT)
+ iReservedSectors=1;
+ iRootDirEntries=2*(4*KDefaultSectorSize)/sizeof(SFatDirEntry);
+ TInt minSectorsPerCluster=(aDiskSizeInSectors+KMaxFAT16Entries-1)/KMaxFAT16Entries;
+ iSectorsPerCluster=1;
+ while (minSectorsPerCluster>iSectorsPerCluster)
+ iSectorsPerCluster<<=1;
+ __PRINT1(_L("iSectorsPerCluster = %d"),iSectorsPerCluster);
+ iSectorsPerFat=MaxFat16Sectors();
+ __PRINT1(_L("iSectorsPerFat = %d"),iSectorsPerFat);
+ iFileSystemName=KFileSystemName16;
- return KErrNone;
- }
+ return KErrNone;
+ }
TInt CFatFormatCB::HandleCorrupt(TInt aError)
//
@@ -230,10 +238,10 @@
// @see TErrorInfo
//
{
- __PRINT2(_L("CFatFormatCB::HandleCorrupt(%d) drv:%d"), aError, Drive().DriveNumber());
+ __PRINT2(_L("CFatFormatCB::HandleCorrupt(%d) drv:%d"), aError, Drive().DriveNumber());
TPckgBuf<TErrorInfo> info;
- TInt r = LocalDrive()->GetLastErrorInfo(info);
+ TInt r = LocalDrive()->GetLastErrorInfo(info);
if(r != KErrNone)
{
@@ -241,15 +249,15 @@
}
if (r == KErrNotSupported)
- return KErrCorrupt;
+ return KErrCorrupt;
else if (r != KErrNone)
return r;
__PRINT3(_L("....TErrorInfo iReasonCode:%d, iErrorPos:%LU, iOtherInfo:%d"), info().iReasonCode, info().iErrorPos, info().iOtherInfo);
-
+
// if no error reported by GetLastErrorInfo(), return the original error
- if (info().iReasonCode == KErrNone)
- return aError;
+ if (info().iReasonCode == KErrNone)
+ return aError;
if (info().iReasonCode!=KErrNone && info().iReasonCode!=TErrorInfo::EBadSector)
return info().iReasonCode;