os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_fmt.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32\sfile\sf_fmt.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "sf_std.h"
sl@0
    19
sl@0
    20
LOCAL_C CFormatCB* GetFormatFromHandle(TInt aHandle,CSessionFs* aSession)
sl@0
    21
//
sl@0
    22
// Get the format control block from aHandle
sl@0
    23
//
sl@0
    24
	{
sl@0
    25
	return((CFormatCB*)(SessionObjectFromHandle(aHandle,Formats->UniqueID(),aSession)));
sl@0
    26
	}
sl@0
    27
sl@0
    28
sl@0
    29
sl@0
    30
/**
sl@0
    31
Default constructor.
sl@0
    32
*/
sl@0
    33
EXPORT_C CFormatCB::CFormatCB()
sl@0
    34
	{
sl@0
    35
	}
sl@0
    36
sl@0
    37
sl@0
    38
sl@0
    39
sl@0
    40
/**
sl@0
    41
    Destructor.
sl@0
    42
    Frees resources before destruction of the object.
sl@0
    43
*/
sl@0
    44
EXPORT_C CFormatCB::~CFormatCB()
sl@0
    45
	{
sl@0
    46
sl@0
    47
	if (iMount)
sl@0
    48
		{
sl@0
    49
		RemoveDiskAccess(*iMount);
sl@0
    50
		iMount->Drive().SetChanged(ETrue);
sl@0
    51
		iMount->Close();
sl@0
    52
		}
sl@0
    53
	}
sl@0
    54
sl@0
    55
sl@0
    56
sl@0
    57
sl@0
    58
/**
sl@0
    59
    Checks that the disk media is still mounted.
sl@0
    60
    @return KErrNone if the media is still mounted; KErrDisMounted otherwise.
sl@0
    61
*/
sl@0
    62
EXPORT_C TInt CFormatCB::CheckMount()
sl@0
    63
	{
sl@0
    64
sl@0
    65
	TDrive& d=Drive();
sl@0
    66
	TInt r=d.CheckMount();
sl@0
    67
	if (r!=KErrNone)
sl@0
    68
		return(r);
sl@0
    69
	if (&Mount()!=&d.CurrentMount())
sl@0
    70
		return(KErrDisMounted);
sl@0
    71
	return(KErrNone);
sl@0
    72
	}
sl@0
    73
sl@0
    74
void CFormatCB::InitL(TDrive* aDrive,TFormatMode aMode)
sl@0
    75
	{
sl@0
    76
	DoInitL(aDrive->DriveNumber());
sl@0
    77
	iDrive=aDrive;
sl@0
    78
	iMount=&iDrive->CurrentMount();
sl@0
    79
	iMode=aMode;
sl@0
    80
	User::LeaveIfError(iMount->Open());
sl@0
    81
	}
sl@0
    82
sl@0
    83
sl@0
    84
EXPORT_C TInt CFormatCB::GetInterface(TInt /*aInterfaceId*/,TAny*& /*aInterface*/,TAny* /*aInput*/)
sl@0
    85
	{
sl@0
    86
	return(KErrNotSupported);
sl@0
    87
	}
sl@0
    88
sl@0
    89
sl@0
    90
//----------------------------------------------------------------------------
sl@0
    91
/** 
sl@0
    92
    set volume formatting parameters, which are provided in TLDFormatInfo structure 
sl@0
    93
    @param  apLDFormatInfo  pointer to the parameters structure. If NULL, iSpecialInfo will be initialised
sl@0
    94
*/
sl@0
    95
void CFormatCB::SetFormatParameters(const TLDFormatInfo* apLDFormatInfo)
sl@0
    96
    {
sl@0
    97
    TLDFormatInfo& fmtInfo = iSpecialInfo();
sl@0
    98
sl@0
    99
    if(!apLDFormatInfo)
sl@0
   100
        {//-- special meaning; invalidate iSpecialInfo by setting its package size as 0
sl@0
   101
        iSpecialInfo.SetLength(0);
sl@0
   102
        }
sl@0
   103
    else
sl@0
   104
        {
sl@0
   105
        Mem::Copy(&fmtInfo, apLDFormatInfo, sizeof(TLDFormatInfo));
sl@0
   106
        }
sl@0
   107
    }
sl@0
   108
sl@0
   109
//----------------------------------------------------------------------------
sl@0
   110
/** set volume formatting parameters, which are provided in TVolFormatParam structure */
sl@0
   111
TInt CFormatCB::SetFormatParameters(const TVolFormatParam* apVolFormatParam)
sl@0
   112
    {
sl@0
   113
    ASSERT(apVolFormatParam);
sl@0
   114
    TAny* dummy;
sl@0
   115
    //-- push parameters to the particular implementation of the CFormatCB. Default behaviour: KErrNotSupported
sl@0
   116
    return GetInterface(ESetFmtParameters, dummy, (TAny*)apVolFormatParam);
sl@0
   117
    }
sl@0
   118
sl@0
   119
//----------------------------------------------------------------------------
sl@0
   120
#ifdef _DEBUG
sl@0
   121
#define DUMP_OPENED_OBJECTS
sl@0
   122
#endif
sl@0
   123
sl@0
   124
/**
sl@0
   125
    Debug helper method. Dumps names of opened files and directories on this drive
sl@0
   126
    define DUMP_OPENED_OBJECTS to have it called
sl@0
   127
*/
sl@0
   128
#ifdef DUMP_OPENED_OBJECTS
sl@0
   129
static void DumpOpenedObjects(TDrive& aDrive)
sl@0
   130
    {
sl@0
   131
        {//-- 1. files 
sl@0
   132
        const TInt nFiles = Files->Count();
sl@0
   133
        for(TInt i=0; i<nFiles; ++i)
sl@0
   134
            {
sl@0
   135
            CFileCB* pFile=(CFileCB*)(*Files)[i];
sl@0
   136
            if(pFile->Drive().DriveNumber() == aDrive.DriveNumber())
sl@0
   137
                {
sl@0
   138
                __PRINT1(_L("FsFormatOpen() opened file:'%S'"), &pFile->FileName());
sl@0
   139
                }
sl@0
   140
            }
sl@0
   141
        
sl@0
   142
        }
sl@0
   143
sl@0
   144
        {//-- 2. directories; CDirCB doesn't have associated name.
sl@0
   145
        const TInt nDirs = Dirs->Count();
sl@0
   146
        TInt cntDirs = 0;
sl@0
   147
        for(TInt i=0; i<nDirs; ++i)
sl@0
   148
            {
sl@0
   149
            CDirCB* pDir = (CDirCB*)(*Dirs)[i];
sl@0
   150
            if(pDir->Drive().DriveNumber() == aDrive.DriveNumber())
sl@0
   151
                {
sl@0
   152
                ++cntDirs;
sl@0
   153
                }
sl@0
   154
            }
sl@0
   155
            
sl@0
   156
        if(cntDirs)
sl@0
   157
            {
sl@0
   158
            __PRINT1(_L("FsFormatOpen() opened directories:%d"), cntDirs);
sl@0
   159
            }
sl@0
   160
sl@0
   161
        }
sl@0
   162
sl@0
   163
    }
sl@0
   164
#endif //DUMP_OPENED_OBJECTS
sl@0
   165
sl@0
   166
//----------------------------------------------------------------------------
sl@0
   167
/**
sl@0
   168
    Open a drive for formatting.
sl@0
   169
*/
sl@0
   170
TInt FsFormatOpen(CFsRequest* aRequest)
sl@0
   171
	{
sl@0
   172
    TDrive& drive = *aRequest->Drive();
sl@0
   173
sl@0
   174
	__PRINT1(_L("FsFormatOpen() drv:%d"), drive.DriveNumber());
sl@0
   175
    
sl@0
   176
    TInt nMountRes = drive.CheckMount();
sl@0
   177
    //-- KErrNotReady means that there is no file system mounted on this drive
sl@0
   178
    //-- KErrInUse means that there are some "disk access" objects, like RFormat or RRawDisk opened on the mount.
sl@0
   179
    if(nMountRes == KErrNotReady || nMountRes == KErrInUse) 
sl@0
   180
        {
sl@0
   181
        __PRINT1(_L("FsFormatOpen() ChkMount:%d"), nMountRes);
sl@0
   182
        return nMountRes;
sl@0
   183
        }
sl@0
   184
    
sl@0
   185
    const TFormatMode fmtMode = (TFormatMode)aRequest->Message().Int1();
sl@0
   186
    TName buf;
sl@0
   187
    TUint32 currFsNameHash = 0; //-- current file system name hash, 0 means "not set"; used during forced FS dismounting
sl@0
   188
sl@0
   189
    if((nMountRes == KErrNone) && drive.CurrentMount().LockStatus() < 0)
sl@0
   190
        {//-- the mount is locked, it has normal objects (files, directories) opened on it. 
sl@0
   191
        
sl@0
   192
        //-- if someone is interested in the list of opened files and number of opened directories, compile this code in.
sl@0
   193
        #ifdef DUMP_OPENED_OBJECTS
sl@0
   194
            DumpOpenedObjects(drive);
sl@0
   195
        #endif //DUMP_OPENED_OBJECTS
sl@0
   196
sl@0
   197
sl@0
   198
        if(!(fmtMode & EForceFormat))
sl@0
   199
            {
sl@0
   200
            __PRINT(_L("FsFormatOpen() The mount is in use"));
sl@0
   201
            return KErrInUse;
sl@0
   202
            }    
sl@0
   203
sl@0
   204
        //-- there is a special flag that tells to force media dismounting even if it has files or dirs opened.
sl@0
   205
        __PRINT(_L("FsFormatOpen() The mount is in use, forcing dismounting!"));
sl@0
   206
sl@0
   207
        //-- record currently mounted FS name hash, it may be used after forced dismounting
sl@0
   208
        drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive
sl@0
   209
        currFsNameHash = TVolFormatParam::CalcFSNameHash(buf);
sl@0
   210
sl@0
   211
        //-- kill the current mount
sl@0
   212
        FsThreadManager::LockDrive(drive.DriveNumber());
sl@0
   213
        TInt nRes = drive.ForceUnmountFileSystemForFormatting();
sl@0
   214
        FsThreadManager::UnlockDrive(drive.DriveNumber());
sl@0
   215
sl@0
   216
        
sl@0
   217
        switch(nRes)
sl@0
   218
            {
sl@0
   219
            case KErrInUse: 
sl@0
   220
            __PRINT(_L("FsFormatOpen() The mount has clamps! Can't force dismount"));    
sl@0
   221
            return KErrInUse; //-- there are clamps on this drive - can't dismount
sl@0
   222
sl@0
   223
            case KErrNone:
sl@0
   224
            break;
sl@0
   225
sl@0
   226
            default:
sl@0
   227
            ASSERT(0); //-- unexpected error code
sl@0
   228
            return nRes;
sl@0
   229
sl@0
   230
            };
sl@0
   231
sl@0
   232
        if(fmtMode & EQuickFormat)
sl@0
   233
            {//-- quick format may require the normally mounted FS, make the best effrot to mount it
sl@0
   234
            nMountRes = drive.CheckMount();
sl@0
   235
            }
sl@0
   236
        else
sl@0
   237
            {//-- this will make the FS mounted by force; for full format it will be quicker
sl@0
   238
            nMountRes = KErrCorrupt;
sl@0
   239
            }
sl@0
   240
sl@0
   241
        }
sl@0
   242
sl@0
   243
	//-- if True, we will need mount (probably specific) file system by force because normal mounting has failed
sl@0
   244
    TBool bNeedForceMount = (nMountRes != KErrNone); 
sl@0
   245
sl@0
   246
    //-- find out if we have optional data structure that describes format parameter
sl@0
   247
    TUint32 newFsNameHash = 0; //-- file system name hash, may be used for selecting which file system to put onto the volume. 0 means "not specified"
sl@0
   248
sl@0
   249
    const TLDFormatInfo*    pLDFormatInfo   = NULL;
sl@0
   250
    const TVolFormatParam*  pVolFormatParam = NULL;
sl@0
   251
sl@0
   252
    __ASSERT_COMPILE(sizeof(TVolFormatParam) >= sizeof(TLDFormatInfo));
sl@0
   253
    TBuf8<sizeof(TVolFormatParam)> paramBuf;
sl@0
   254
   
sl@0
   255
    
sl@0
   256
    if(fmtMode & ESpecialFormat)  
sl@0
   257
        {   
sl@0
   258
        //-- the user has provided format parameters structure.
sl@0
   259
        //-- IPC argument #2 contains a structure: <TUint32>[optional package descriptor]
sl@0
   260
        //-- where 1st mandatory TUint32 is a pointer to format counter and the optional additional package is a data structure passed to the filesystem by the client of RFormat
sl@0
   261
        const TInt desLen = aRequest->GetDesLength(KMsgPtr2);
sl@0
   262
        ASSERT((TUint32)desLen >= sizeof(TUint32));
sl@0
   263
    
sl@0
   264
        const TInt dataPckgLen = desLen - sizeof(TUint32);
sl@0
   265
sl@0
   266
        if((TUint32)dataPckgLen > sizeof(TUint32))
sl@0
   267
            {
sl@0
   268
            aRequest->ReadL(KMsgPtr2, paramBuf); 
sl@0
   269
            }
sl@0
   270
        
sl@0
   271
        if(dataPckgLen == sizeof(TLDFormatInfo))
sl@0
   272
            {//-- the user has provided formatting parameters via TLDFormatInfo structure.
sl@0
   273
            pLDFormatInfo = (const TLDFormatInfo*)(paramBuf.Ptr() + sizeof(TUint32));
sl@0
   274
            }
sl@0
   275
        else if(dataPckgLen == sizeof(TVolFormatParam))
sl@0
   276
            {//-- it's likely to be TVolFormatParam, need to check UId to be sure.
sl@0
   277
            pVolFormatParam = (const TVolFormatParam*)(const TVolFormatParam*)(paramBuf.Ptr() + sizeof(TUint32));
sl@0
   278
sl@0
   279
            if(pVolFormatParam->iUId == TVolFormatParam::KUId)  //-- check the class UID
sl@0
   280
                {//-- this is the real TVolFormatParam object passed
sl@0
   281
                newFsNameHash = pVolFormatParam->FSNameHash();
sl@0
   282
                }
sl@0
   283
            }
sl@0
   284
        else if(dataPckgLen >0)
sl@0
   285
            {//-- parameters data structure has strange length
sl@0
   286
            return KErrArgument;
sl@0
   287
            }
sl@0
   288
    
sl@0
   289
        }
sl@0
   290
sl@0
   291
    //-------------------
sl@0
   292
    if(!newFsNameHash && currFsNameHash)
sl@0
   293
        {//-- new file system name isn't specified (default formatting), but the volume had been forcedly dismounted.
sl@0
   294
         //-- restore the original file system   
sl@0
   295
        newFsNameHash = currFsNameHash;
sl@0
   296
        }
sl@0
   297
    
sl@0
   298
    if(newFsNameHash)
sl@0
   299
        {//-- check if the specified FS is already mounted on the volume
sl@0
   300
        if(!bNeedForceMount)
sl@0
   301
            {
sl@0
   302
            drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive
sl@0
   303
            }
sl@0
   304
        else
sl@0
   305
            { //-- the iCurrentMount can be NULL, use the iFsys - the real file system associated with this drive
sl@0
   306
            buf = drive.GetFSys()->Name();
sl@0
   307
            }
sl@0
   308
sl@0
   309
        const TUint32 currFSNameHash = TVolFormatParam::CalcFSNameHash(buf);
sl@0
   310
        if(currFSNameHash == newFsNameHash)
sl@0
   311
            {//-- no need to do anything, the required FS is already mounted
sl@0
   312
            newFsNameHash = 0; 
sl@0
   313
            } 
sl@0
   314
        }
sl@0
   315
sl@0
   316
    if(newFsNameHash) 
sl@0
   317
        {
sl@0
   318
        //-- the user has specified some filesystem to be mounted on the volume. Check if this FS is supported at all.
sl@0
   319
        //-- if it is supported, but some other FS is currently mounted, it will be dismounted and the new one will be forced.
sl@0
   320
        TInt nRes;
sl@0
   321
            
sl@0
   322
        for(TInt cntFS=0; ;++cntFS)
sl@0
   323
            {
sl@0
   324
            nRes = drive.FSys().GetSupportedFileSystemName(cntFS, buf); //-- enumerate possible child file systems
sl@0
   325
            
sl@0
   326
            if(nRes != KErrNone)
sl@0
   327
                return KErrNotSupported; //-- the filesystem with the given name (fsNameHash) is not supported.
sl@0
   328
sl@0
   329
            if(newFsNameHash == TVolFormatParam::CalcFSNameHash(buf))
sl@0
   330
                {//-- the filesystem with the given name (fsNameHash) is supported, but some other filesystem can be already mounted
sl@0
   331
                drive.Dismount();
sl@0
   332
                bNeedForceMount = ETrue; //-- this will force the desired FS to be mounted
sl@0
   333
                break;
sl@0
   334
                }
sl@0
   335
            }
sl@0
   336
    
sl@0
   337
        }//if(fsNameHash) 
sl@0
   338
sl@0
   339
sl@0
   340
    //-- try force mounting the desired file system if it is required
sl@0
   341
    if(bNeedForceMount)
sl@0
   342
        {
sl@0
   343
        const TInt KMaxRetries = 3;
sl@0
   344
        for(TInt cnt=0; ; ++cnt)
sl@0
   345
            {
sl@0
   346
            drive.MountFileSystem(ETrue, newFsNameHash);
sl@0
   347
sl@0
   348
            nMountRes = drive.GetReason();
sl@0
   349
            if(nMountRes == KErrNone || nMountRes == KErrLocked)
sl@0
   350
                break;
sl@0
   351
            
sl@0
   352
            drive.Dismount(); //-- will reset mount retries counter
sl@0
   353
            
sl@0
   354
            if(cnt >= KMaxRetries)
sl@0
   355
                {
sl@0
   356
                __PRINT1(_L("FsFormatOpen() can't mount FS! res:%d"), nMountRes);    
sl@0
   357
                return nMountRes;
sl@0
   358
                }
sl@0
   359
            }
sl@0
   360
        }
sl@0
   361
sl@0
   362
    ASSERT(nMountRes == KErrNone || nMountRes == KErrLocked);
sl@0
   363
    
sl@0
   364
    __ASSERT_DEBUG(drive.CurrentMount().LockStatus()==0, Fault(ESvrFormatOpenFailed));
sl@0
   365
sl@0
   366
sl@0
   367
	TDriveInfo dInfo;
sl@0
   368
	drive.DriveInfo(dInfo);
sl@0
   369
	const TInt mediaAtt = dInfo.iMediaAtt;
sl@0
   370
sl@0
   371
#if defined(_LOCKABLE_MEDIA)
sl@0
   372
	if (!(fmtMode & EForceErase) && (mediaAtt & KMediaAttLocked))
sl@0
   373
		{
sl@0
   374
		// if attempting to format a locked drive, dismount otherwise subsequent 
sl@0
   375
		// requests will operate on a mount that has been forcibly mounted (a few lines above)
sl@0
   376
		CMountCB* pM = &drive.CurrentMount();
sl@0
   377
		
sl@0
   378
        if(pM)
sl@0
   379
			pM->Close();
sl@0
   380
sl@0
   381
		drive.MountFileSystem(EFalse);	// clear iCurrentMount
sl@0
   382
		return KErrLocked;
sl@0
   383
		}
sl@0
   384
#endif
sl@0
   385
sl@0
   386
	if (!(mediaAtt & KMediaAttFormattable) || (mediaAtt & KMediaAttWriteProtected))
sl@0
   387
		{
sl@0
   388
		CMountCB* pM = &drive.CurrentMount();
sl@0
   389
		
sl@0
   390
        if(pM)
sl@0
   391
			pM->Close();
sl@0
   392
sl@0
   393
		drive.MountFileSystem(EFalse);
sl@0
   394
        return KErrAccessDenied;
sl@0
   395
		}
sl@0
   396
sl@0
   397
	//-- instantinate and open CFormatCB object for this drive
sl@0
   398
    CFormatCB* formatCB=NULL;
sl@0
   399
	TInt fmtHandle;
sl@0
   400
    
sl@0
   401
    TRAPD(ret, formatCB = drive.FormatOpenL(aRequest, fmtHandle, fmtMode, pLDFormatInfo, pVolFormatParam ));
sl@0
   402
sl@0
   403
	if (ret!=KErrNone)
sl@0
   404
		{
sl@0
   405
		if(formatCB)
sl@0
   406
			formatCB->Close();
sl@0
   407
sl@0
   408
		return ret;
sl@0
   409
		}
sl@0
   410
sl@0
   411
	TPtrC8 pH((TUint8*)&fmtHandle,sizeof(TInt));
sl@0
   412
	aRequest->WriteL(KMsgPtr3,pH);
sl@0
   413
	TInt count=100;
sl@0
   414
sl@0
   415
	TPtrC8 pCount((TUint8*)&count,sizeof(TInt));
sl@0
   416
	aRequest->WriteL(KMsgPtr2,pCount);
sl@0
   417
	aRequest->Session()->IncResourceCount();
sl@0
   418
	
sl@0
   419
    return KErrNone;
sl@0
   420
	}
sl@0
   421
sl@0
   422
TInt TFsFormatOpen::DoRequestL(CFsRequest* aRequest)
sl@0
   423
//
sl@0
   424
// Open a drive for formatting.
sl@0
   425
//
sl@0
   426
	{
sl@0
   427
	// Can not format if any files are clamped
sl@0
   428
	TInt r=FsFormatOpen(aRequest);
sl@0
   429
	return r;
sl@0
   430
	}
sl@0
   431
sl@0
   432
TInt TFsFormatOpen::Initialise(CFsRequest* aRequest)
sl@0
   433
//
sl@0
   434
//
sl@0
   435
//
sl@0
   436
	{
sl@0
   437
	TInt r;
sl@0
   438
	if (!KCapFsFormatOpen.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Format Open")))
sl@0
   439
		return KErrPermissionDenied;
sl@0
   440
	r=ParseNoWildSubstPtr0(aRequest,aRequest->Src());
sl@0
   441
	if (r!=KErrNone)
sl@0
   442
		return(r);
sl@0
   443
	if (aRequest->Src().NameOrExtPresent())
sl@0
   444
		return(KErrBadName);
sl@0
   445
	if (aRequest->SubstedDrive())
sl@0
   446
		return(KErrAccessDenied);
sl@0
   447
	return(r);
sl@0
   448
	}
sl@0
   449
sl@0
   450
sl@0
   451
TInt TFsFormatNext::DoRequestL(CFsRequest* aRequest)
sl@0
   452
//
sl@0
   453
// Format the next part of the media.
sl@0
   454
//
sl@0
   455
	{
sl@0
   456
sl@0
   457
	__PRINT1(_L("TFsFormatNext::DoRequestL() drv:%d"), aRequest->DriveNumber());
sl@0
   458
	CFormatCB* format=(CFormatCB*)aRequest->ScratchValue();
sl@0
   459
	TInt r=format->CheckMount();
sl@0
   460
	if (r!=KErrNone && r!=KErrInUse)
sl@0
   461
        {
sl@0
   462
    	__PRINT1(_L("TFsFormatNext::DoRequestL() err:%d"), r);
sl@0
   463
        return r;
sl@0
   464
        }
sl@0
   465
sl@0
   466
	TPtr8 pStep((TUint8*)&format->CurrentStep(),sizeof(TInt));
sl@0
   467
	aRequest->ReadL(KMsgPtr0,pStep);
sl@0
   468
sl@0
   469
	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFormatCBDoFormatStepL, EF32TraceUidFileSys, format);
sl@0
   470
	TRAP(r,format->DoFormatStepL());
sl@0
   471
	TRACERET2(UTF::EBorder, UTraceModuleFileSys::ECFormatCBDoFormatStepLRet, EF32TraceUidFileSys, r, format->CurrentStep());
sl@0
   472
sl@0
   473
	if (r==KErrNone)
sl@0
   474
		aRequest->WriteL(KMsgPtr0,pStep);
sl@0
   475
	if (r==KErrNone && format->CurrentStep()==0)
sl@0
   476
		{
sl@0
   477
		FsNotify::DiskChange(aRequest->DriveNumber());
sl@0
   478
		}
sl@0
   479
	return(r);
sl@0
   480
	}
sl@0
   481
sl@0
   482
TInt TFsFormatNext::Initialise(CFsRequest* aRequest)
sl@0
   483
//
sl@0
   484
//
sl@0
   485
//
sl@0
   486
	{
sl@0
   487
	if (!KCapFsFormatNext.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Format Next")))
sl@0
   488
		return KErrPermissionDenied;
sl@0
   489
	CFormatCB* format;
sl@0
   490
	format=GetFormatFromHandle(aRequest->Message().Int3(), aRequest->Session());
sl@0
   491
	if(!format)
sl@0
   492
		return(KErrBadHandle);	
sl@0
   493
	aRequest->SetDrive(&format->Drive());
sl@0
   494
	aRequest->SetScratchValue((TUint)format);
sl@0
   495
	return KErrNone;
sl@0
   496
	}