sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\lffs\loadlffs.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: LOCAL_C void FormatLFFS(TDes &drive) sl@0: { sl@0: sl@0: RFormat format; sl@0: TInt count; sl@0: TInt r; sl@0: sl@0: RDebug::Print(_L("Format LFFS drive %S\r\n"), &drive); sl@0: r = format.Open(TheFs, drive, EHighDensity, count); sl@0: sl@0: while (count) sl@0: { sl@0: format.Next(count); sl@0: } sl@0: sl@0: format.Close(); sl@0: } sl@0: sl@0: sl@0: //LOCAL_C void ForceMediaRemount( TMediaDevice aMedia ) sl@0: // // sl@0: // // Force a remount on next access sl@0: // // sl@0: // { sl@0: // UserSvr::ForceRemountMedia( aMedia ); sl@0: // } sl@0: sl@0: sl@0: sl@0: TInt MountLFFS() sl@0: { sl@0: RDebug::Print(_L("Read machine information")); sl@0: sl@0: TInt LFFSdriveNumber; sl@0: TBuf<4> LFFSdriveLetter; sl@0: sl@0: LFFSdriveLetter.Zero(); sl@0: LFFSdriveLetter.Append(_L("K:\\")); sl@0: LFFSdriveNumber = EDriveK; sl@0: sl@0: RDebug::Print(_L("Load device driver: MEDLFS")); sl@0: TInt r=User::LoadPhysicalDevice(_L("MEDLFS")); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: { sl@0: RDebug::Print(_L("Loading device driver failed")); sl@0: return(-1); sl@0: } sl@0: sl@0: RDebug::Print(_L("Add file system: ELFFS")); sl@0: r=TheFs.AddFileSystem(_L("ELFFS")); sl@0: if(r != KErrNone && r != KErrAlreadyExists) sl@0: RDebug::Print(_L("Failed to add ELFFS")); sl@0: sl@0: sl@0: TFullName name; sl@0: r = TheFs.FileSystemName(name, LFFSdriveNumber); sl@0: sl@0: if (name.Length() != 0) sl@0: { sl@0: RDebug::Print(_L("Dismounting %S on drive %S\r\n"), &name, &LFFSdriveLetter); sl@0: r=TheFs.DismountFileSystem(name, LFFSdriveNumber); sl@0: RDebug::Print(_L("Dismount ret=%d"), r); sl@0: } sl@0: sl@0: // ForceMediaRemount( EFixedMedia1 ); sl@0: sl@0: RDebug::Print(_L("Mount LFFS on drive %S\r\n"), &LFFSdriveLetter); sl@0: r=TheFs.MountFileSystem(_L("Lffs"), LFFSdriveNumber); sl@0: RDebug::Print(_L("Mount r=%d"),r); sl@0: //uncommented sl@0: if (r == KErrCorrupt || r == KErrNotReady) sl@0: { sl@0: RDebug::Print(_L("FS Corrupt, formatting")); sl@0: FormatLFFS(LFFSdriveLetter); sl@0: } sl@0: ///to here sl@0: TheFs.SetSessionPath(LFFSdriveLetter); sl@0: return(LFFSdriveNumber); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Load the LFFS on C: sl@0: // sl@0: { sl@0: sl@0: CTrapCleanup* cleanup; sl@0: cleanup=CTrapCleanup::New(); sl@0: sl@0: TInt r=TheFs.Connect(); sl@0: RDebug::Print(_L("Connect ret %d"),r); sl@0: sl@0: TRAP(r,MountLFFS()); sl@0: RDebug::Print(_L("Mount LFFS ret %d"),r); sl@0: sl@0: TheFs.Close(); sl@0: delete cleanup; sl@0: return(KErrNone); sl@0: } sl@0: