os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_fmt.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfsrv/cl_fmt.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,195 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32\sfsrv\cl_fmt.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "cl_std.h"
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +EXPORT_C TInt RFormat::Open(RFs& aFs,const TDesC& aName,TUint aFormatMode,TInt& aCount)
    1.27 +/**
    1.28 +Opens a device for formatting.
    1.29 +
    1.30 +The device may be formatted either at high or low density.
    1.31 +
    1.32 +Devices which support read-only media may not be formatted. This includes
    1.33 +the ROM on drive Z:. All files on the drive must be closed otherwise
    1.34 +an error is returned.
    1.35 +
    1.36 +@param aFs          The file server session. Must be connected.
    1.37 +@param aName        The drive to be formatted, specified as a drive letter
    1.38 +                    followed by a colon.
    1.39 +@param aFormatMode  The format mode. See TFormatMode.
    1.40 +@param aCount       On successful return, contains the number of tracks which
    1.41 +                    remain to be formatted. This value is passed to the first
    1.42 +                    iteration of Next(), which then decrements the value on
    1.43 +                    this and subsequent calls to Next().
    1.44 +                    
    1.45 +@return KErrNone, if successful, otherwise one of the other system wide error
    1.46 +        codes.
    1.47 +
    1.48 +@see TFormatMode
    1.49 +
    1.50 +@capability DiskAdmin
    1.51 +
    1.52 +*/
    1.53 +	{
    1.54 +	TRACEMULT3(UTF::EBorder, UTraceModuleEfsrv::EFormat1Open, MODULEUID, aFs.Handle(), aName, aFormatMode);
    1.55 +
    1.56 +	TPtr8 c((TUint8*)&aCount,sizeof(TUint),sizeof(TUint));
    1.57 +	TInt r = CreateSubSession(aFs,EFsFormatOpen,TIpcArgs(&aName,aFormatMode,&c));
    1.58 +
    1.59 +	TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFormatOpen1Return, MODULEUID, r, SubSessionHandle(), aCount);
    1.60 +	return r;
    1.61 +	}
    1.62 +
    1.63 +
    1.64 +EXPORT_C TInt RFormat::Open(RFs& aFs,const TDesC& aName,TUint aFormatMode,TInt& aCount,const TDesC8& aInfo)
    1.65 +/**
    1.66 +Opens a device for formatting. User can specify new format parameters by anInfo.
    1.67 +
    1.68 +The device may be formatted either at high or low density.
    1.69 +
    1.70 +Devices which support read-only media may not be formatted. This includes
    1.71 +the ROM on drive Z:. All files on the drive must be closed otherwise
    1.72 +an error is returned.
    1.73 +
    1.74 +@param aFs          The file server session. Must be connected.
    1.75 +@param aName        The drive to be formatted, specified as a drive letter
    1.76 +                    followed by a colon.
    1.77 +@param aFormatMode  The format mode. See TFormatMode.
    1.78 +@param aCount       On successful return, contains the number of tracks which
    1.79 +                    remain to be formatted. This value is passed to the first
    1.80 +                    iteration of Next(), which then decrements the value on
    1.81 +                    this and subsequent calls to Next().
    1.82 +@param anInfo       Special format information specified by user.
    1.83 +                    
    1.84 +@return KErrNone, if successful, otherwise one of the other system wide error
    1.85 +        codes.
    1.86 +
    1.87 +@see TFormatMode
    1.88 +
    1.89 +@capability DiskAdmin
    1.90 +*/
    1.91 +	{
    1.92 +	TRACEMULT4(UTF::EBorder, UTraceModuleEfsrv::EFormat2Open, MODULEUID, aFs.Handle(), aName, aFormatMode, TUint(&aInfo));
    1.93 +
    1.94 +	TInt size = sizeof(TUint)+aInfo.Length();
    1.95 +	TUint8* buf = new TUint8[size];
    1.96 +
    1.97 +	TInt r;
    1.98 +	if (!buf)
    1.99 +		{
   1.100 +	    r = KErrNoMemory;
   1.101 +		}
   1.102 +	else
   1.103 +		{
   1.104 +		TPtr8 c(buf, size);
   1.105 +		c.Append((TUint8*)&aCount, sizeof(TUint));
   1.106 +		c.Append(aInfo);
   1.107 +		r = CreateSubSession(aFs,EFsFormatOpen,TIpcArgs(&aName,aFormatMode,&c));
   1.108 +		aCount = *(TInt*)(&c[0]);
   1.109 +		delete[] buf;
   1.110 +		}
   1.111 +
   1.112 +	TRACERET3(UTF::EBorder, UTraceModuleEfsrv::EFormatOpen2Return, MODULEUID, r, SubSessionHandle(), aCount);
   1.113 +	return r;
   1.114 +	}
   1.115 +
   1.116 +
   1.117 +
   1.118 +EXPORT_C void RFormat::Close()
   1.119 +/**
   1.120 +Closes the Format subsession.
   1.121 +
   1.122 +Any open files are closed when the file server session is closed.
   1.123 +
   1.124 +Close() is guaranteed to return, and provides no indication whether
   1.125 +it completed successfully or not.
   1.126 +*/
   1.127 +	{
   1.128 +	TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFormatClose, MODULEUID, Session().Handle(), SubSessionHandle());
   1.129 +
   1.130 +	CloseSubSession(EFsFormatSubClose);
   1.131 +	
   1.132 +	TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFormatCloseReturn, MODULEUID);
   1.133 +	}
   1.134 +
   1.135 +
   1.136 +
   1.137 +EXPORT_C TInt RFormat::Next(TInt& aStep)
   1.138 +/**
   1.139 +Executes the next format step.
   1.140 +
   1.141 +This is a synchronous function, which returns when the formatting step
   1.142 +is complete.
   1.143 +
   1.144 +@param aStep The step number. On return, it is decremented to indicate what
   1.145 +			 stage the formatting has reached. Before the first call to this
   1.146 +			 function, this value is seeded with the number of tracks remaining
   1.147 +			 to be formatted as returned by RFormat::Open().
   1.148 +			 The function should be called repeatedly until aStep reaches zero.
   1.149 +			 
   1.150 +@return KErrNone, if successful, otherwise one of the other system wide error codes.
   1.151 +
   1.152 +@see RFormat::Open
   1.153 +
   1.154 +@capability DiskAdmin
   1.155 +
   1.156 +*/
   1.157 +	{
   1.158 +	TRACE2(UTF::EBorder, UTraceModuleEfsrv::EFormatNext1, MODULEUID, Session().Handle(), SubSessionHandle());
   1.159 +
   1.160 +	TPckg<TInt> e(aStep);
   1.161 +	TInt r = SendReceive(EFsFormatNext,TIpcArgs(&e));
   1.162 +
   1.163 +	TRACERET2(UTF::EBorder, UTraceModuleEfsrv::EFormatNext1Return, MODULEUID, r, aStep);
   1.164 +	return r;
   1.165 +	}
   1.166 +
   1.167 +
   1.168 +
   1.169 +
   1.170 +EXPORT_C void RFormat::Next(TPckgBuf<TInt>& aStep,TRequestStatus& aStatus)
   1.171 +/**
   1.172 +Executes the next format step.
   1.173 +
   1.174 +This is an asynchronous function.
   1.175 +
   1.176 +@param aStep The step number. On return, it is decremented to indicate what
   1.177 +			 stage the formatting has reached. Before the first call to this
   1.178 +			 function, this value is seeded with the number of tracks remaining
   1.179 +			 to be formatted as returned by RFormat::Open().
   1.180 +			 The function should be called repeatedly until aStep reaches zero.
   1.181 +			 
   1.182 +@param aStatus The request status. On request completion, contains a completion
   1.183 +			   code:
   1.184 +			   KErrNone, if successful, otherwise one of the other system-wide
   1.185 +               error codes.
   1.186 +
   1.187 +@see RFormat::Open
   1.188 +
   1.189 +@capability DiskAdmin
   1.190 +
   1.191 +*/
   1.192 +	{
   1.193 +	TRACE3(UTF::EBorder, UTraceModuleEfsrv::EFormatNext2, MODULEUID, Session().Handle(), SubSessionHandle(), &aStatus);
   1.194 +
   1.195 +	SendReceive(EFsFormatNext,TIpcArgs(&aStep),aStatus);
   1.196 +
   1.197 +	TRACE0(UTF::EBorder, UTraceModuleEfsrv::EFormatNext2Return, MODULEUID);
   1.198 +	}