/** Tries to restore the original FS on the drive using the FS descriptor provided @return standard error code. */ static TInt DoRestoreFS(RFs& aFs, TInt aDrive, CFileSystemDescriptor* apFsDesc) { TInt nRes; Log(_L("# DoRestoreFS drv:%d\n"), aDrive); //-- 1. check that there is no FS installed { TBuf<128> fsName; nRes = aFs.FileSystemName(fsName, aDrive); if(nRes == KErrNone) {//-- probably no file system installed at all Log(_L("# This drive already has FS intalled:%S \n"), &fsName); return KErrAlreadyExists; } } TPtrC ptrN (apFsDesc->FsName()); TPtrC ptrExt(apFsDesc->PrimaryExtName()); Log(_L("# Mounting FS:%S, Prim ext:%S, synch:%d\n"), &ptrN, &ptrExt, apFsDesc->DriveIsSynch()); if(ptrExt.Length() >0) {//-- there is a primary extension to be mounted nRes = aFs.AddExtension(ptrExt); if(nRes != KErrNone && nRes != KErrAlreadyExists) { return nRes; } nRes = aFs.MountFileSystem(ptrN, ptrExt, aDrive, apFsDesc->DriveIsSynch()); } else { nRes = aFs.MountFileSystem(ptrN, aDrive, apFsDesc->DriveIsSynch()); } if(nRes != KErrNone) { Log(_L("# Mount failed! code:%d\n"),nRes); } return nRes; }