diff -r 947f0dc9f7a8 -r 6e99f362aa46 userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsproxy.cpp --- a/userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsproxy.cpp Fri Apr 16 16:24:37 2010 +0300 +++ b/userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsproxy.cpp Fri Apr 23 21:54:44 2010 +0100 @@ -1,24 +1,18 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of the License "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". // -// hostusbmsproxy.cpp +// Initial Contributors: +// Nokia Corporation - initial contribution. // -// This file system extension provides a way to access a drive on the MS system in "raw format". -// It can be used to test large files / drives +// Contributors: +// +// Description: +// This file system extension provides a way to access a drive on the MS system +// in "raw format". It can be used to test large files / drives // /** @file @@ -46,14 +40,19 @@ TInt CUsbHostMsProxyDrive::InitialiseOffset(TCapsInfo& aCapsInfo) { __MSFNSLOG - const TInt KPartitionInfoSize = TMsDataMemMap::KSectorSize; - TBuf8 partitionInfo; - TInt r; + RBuf8 partitionInfo; + TInt r; + TRAP(r, partitionInfo.CreateL(aCapsInfo.iBlockLength)); + if (r != KErrNone) + { + return r; + } - r = iUsbHostMsLun.Read(0 , KPartitionInfoSize, (TDes8 &) partitionInfo); + r = iUsbHostMsLun.Read(0, aCapsInfo.iBlockLength, partitionInfo); if (r != KErrNone) { __PXYPRINT1(_L("!! Reading medium failed with %d !!"), r); + partitionInfo.Close(); return r; } TUint8 *iIntBuf = (TUint8 *) partitionInfo.Ptr(); @@ -110,21 +109,27 @@ TMBRPartitionEntry& partitionEntry = pe[partitionIndex]; iMsDataMemMap.InitDataArea(partitionEntry.iFirstSector, - partitionEntry.iNumSectors); + partitionEntry.iNumSectors, + aCapsInfo.iBlockLength); __PXYPRINT2(_L("paritioncount = %d defaultpartition = %d"), partitionCount, partitionIndex); - __PXYPRINT2(_L("iFirstSector = x%x iNumSectors = x%x"), + __PXYPRINT3(_L("iFirstSector = x%x iNumSectors = x%x iSectorSize = x%x"), partitionEntry.iFirstSector, - partitionEntry.iNumSectors); + partitionEntry.iNumSectors, + aCapsInfo.iBlockLength); } else { __PXYPRINT(_L("No partition found")); - iMsDataMemMap.InitDataArea(0, aCapsInfo.iNumberOfBlocks); - __PXYPRINT2(_L("iFirstSector = x%x iNumSectors = x%x"), - 0, aCapsInfo.iNumberOfBlocks); + iMsDataMemMap.InitDataArea(0, aCapsInfo.iNumberOfBlocks, aCapsInfo.iBlockLength); + __PXYPRINT3(_L("iFirstSector = x%x iNumSectors = x%x iSectorSize = x%x"), + 0, + aCapsInfo.iNumberOfBlocks, + aCapsInfo.iBlockLength); } } + + partitionInfo.Close(); return KErrNone; } @@ -486,6 +491,7 @@ return KErrNone; } + /** Write to the proxy drive and pass flags to driver @@ -521,6 +527,7 @@ return iUsbHostMsLun.Write(iMsDataMemMap.GetDataPos(aPos), aSrc.Length(), aSrc); } + /** Get the proxy drive's capabilities information. @@ -562,23 +569,33 @@ { c.iMediaAtt |= KMediaAttWriteProtected; } + + static const TInt K512ByteSectorSize = 0x200; // 512 + if(K512ByteSectorSize != capsInfo.iBlockLength) + { + c.iMediaAtt &= ~KMediaAttFormattable; + } __HOSTPRINT4(_L("<<< HOST Caps Block[num=0x%x size=0x%x] Media[size=0x%lx WP=0x%x]"), capsInfo.iNumberOfBlocks, capsInfo.iBlockLength, caps().iSize, caps().iMediaAtt); } - else + else if (KErrNotReady) { __HOSTPRINT(_L("<<< HOST Caps Media Not Present")); - c.iType = EMediaNotPresent; - if(r != KErrNotReady) - r = KErrUnknown; + c.iType = EMediaNotPresent; + r = KErrNone; + } + else + { + __HOSTPRINT(_L("<<< HOST Caps Unknown Error")); + c.iType = EMediaUnknown; + r = KErrUnknown; } anInfo = caps.Left(Min(caps.Length(),anInfo.MaxLength())); return r; } - /** Format the proxy drive. The drive is assumed to be a single partition. The partition size is equivalent to the size of the media. @@ -630,7 +647,7 @@ { __MSFNSLOG - const TInt KDefaultMaxBytesPerFormat = 0x100 * TMsDataMemMap::KSectorSize; // 128K + const TInt KDefaultMaxBytesPerFormat = 0x100 * iMsDataMemMap.BlockLength(); // 128K if (aInfo.i512ByteSectorsFormatted < 0) return KErrArgument; @@ -649,14 +666,14 @@ iMsDataMemMap.InitDataArea(caps().iSize); } - TInt64 pos = static_cast(aInfo.i512ByteSectorsFormatted) << TMsDataMemMap::KFormatSectorShift; + TInt64 pos = static_cast(aInfo.i512ByteSectorsFormatted) << iMsDataMemMap.FormatSectorShift(); TInt length = aInfo.iMaxBytesPerFormat; TInt r = Erase(pos, length); if (r == KErrNone) { - length += TMsDataMemMap::KSectorSize - 1; - length >>= TMsDataMemMap::KFormatSectorShift; + length += iMsDataMemMap.BlockLength() - 1; + length >>= iMsDataMemMap.FormatSectorShift(); aInfo.i512ByteSectorsFormatted += length; }