/** Constructs DCommsbuf based upon underlying shared buffer. Should be constructed in kernel private memory not in place in the buffer. Offset defaults to zero and length to the maximum length @param aShBuf Underlying shared buffer @param aCommsPoolHandle Opaque user side handle (as discovered through driver interface) */ DCommsBuf::DCommsBuf(TShBuf* aShBuf, TInt aCommsPoolHandle, TInt aBufSize) { __ASSERT_COMPILE(sizeof(TCommsBuf) == TCommsBuf::KCommsBufMetadataSize); __ASSERT_COMPILE(sizeof(DCommsBuf) == sizeof(TCommsBuf)); __ASSERT_DEBUG(aCommsPoolHandle, KernCommsBuf::Fault(ECommsBufMetadataCorrupt)); iFrontCanary = KCanaryDefault; TUint8* shBufPtr = Kern::ShBufPtr(aShBuf); iShBuf = aShBuf; iCommsBufPtr = shBufPtr + aBufSize; iRawDataOffset = -aBufSize; iOffset = iRawDataOffset; iRawSize = aBufSize; iLength = aBufSize; iNext = NULL; iPool = aCommsPoolHandle; iHandle = 0; iReservedWords[0] = 0; iReservedWords[1] = 0; iReservedWords[2] = 0; iReservedWords[3] = 0; iReservedWords[4] = 0; iBackCanary = KCanaryDefault; }
/** Constructs the server object, specifying the server type and the active object priority. Derived classes must define and implement a constructor through which the priority can be specified. A typical implementation calls this server base class constructor through a constructor initialization list. @param aPriority The priority of this active object. @param aType Indicates the type of session that the server creates. If not explicitly stated, then the server creates a session that is not sharable with other threads. */ EXPORT_C CServer2::CServer2(TInt aPriority, TServerType aType) : CActive(aPriority), iSessionType((TUint8)aType), iSessionQ(_FOFF(CSession2,iLink)), iSessionIter(iSessionQ) { ASSERT(iSessionType == aType); __ASSERT_COMPILE(EServerRole_Default == 0); __ASSERT_COMPILE(EServerOpt_PinClientDescriptorsDefault == 0); }
/** Initialise this interface. This must be called before any call to OpenL(), to ensure that the RProperties it uses are correctly initialised. */ EXPORT_C void RLbsNetworkPositionUpdates::InitializeL() { // There is an assumption that TPositionSatelliteInfo is the biggest // class to be sent over this interface, so double-check __ASSERT_COMPILE(sizeof(TPositionSatelliteInfo) >= sizeof(TPositionInfo)); __ASSERT_COMPILE(sizeof(TPositionSatelliteInfo) >= sizeof(TPositionCourseInfo)); TSecurityPolicy readPolicy(ECapabilityLocation); TSecurityPolicy writePolicy(ECapabilityWriteDeviceData); // Network reference position property TInt err = RProperty::Define(KNetworkReferencePositionUpdateKey, RProperty::ELargeByteArray, readPolicy, writePolicy, sizeof(TLbsPositionUpdateData)); if (err != KErrNone && err != KErrAlreadyExists) { User::Leave(err); } // Network final position property err = RProperty::Define(KNetworkFinalPositionUpdateKey, RProperty::ELargeByteArray, readPolicy, writePolicy, sizeof(TLbsPositionUpdateData)); if (err != KErrNone && err != KErrAlreadyExists) { User::Leave(err); } // Set default values for the properties TLbsPositionUpdateData defaultData; defaultData.iError = KErrNotFound; defaultData.iTargetTime = 0; defaultData.iActualTime = 0; // indicate that the property is ok, but contains no data. defaultData.iValidData = EFalse; TLbsPositionUpdateDataPckgC pckg(defaultData); User::LeaveIfError(RProperty::Set(RProcess().SecureId(), KNetworkReferencePositionUpdateKey, pckg)); User::LeaveIfError(RProperty::Set(RProcess().SecureId(), KNetworkFinalPositionUpdateKey, pckg)); // Save the Uid of the process which called InitializeL() // in the cenrep file owned by LbsRoot. SetCategoryUidL(KNetworkPositionUpdateCategoryKey, RProcess().SecureId()); }
TInt DMemModelProcess::DoCreate(TBool aKernelProcess, TProcessCreateInfo& aInfo) { // Required so we can detect whether a process has been created and added // to its object container by checking for iContainerID!=EProcess. __ASSERT_COMPILE(EProcess != 0); __KTRACE_OPT(KPROC,Kern::Printf(">DMemModelProcess::DoCreate %O",this)); TInt r=KErrNone; if (aKernelProcess) { iAttributes |= ESupervisor; iOsAsid = KKernelOsAsid; } else { r = MM::AddressSpaceAlloc(iPageDir); if (r>=0) { iOsAsid = r; r = KErrNone; } } if (r == KErrNone) {// Add this process's own reference to its os asid. __e32_atomic_store_ord32(&iOsAsidRefCount, 1); } #ifdef BTRACE_FLEXIBLE_MEM_MODEL BTrace8(BTrace::EFlexibleMemModel,BTrace::EAddressSpaceId,this,iOsAsid); #endif __KTRACE_OPT(KPROC,Kern::Printf("OS ASID=%d, PD=%08x",iOsAsid,iPageDir)); __KTRACE_OPT(KPROC,Kern::Printf("<DMemModelProcess::DoCreate %d",r)); return r; }
// // Location Response Message to PSY // EXPORT_C TLbsCellLocationResponseMsg::TLbsCellLocationResponseMsg(const TLbsNetSessionIdInt& aSessionId, TInt aReason, const TPositionInfoBase& aPosInfo): TLbsNetInternalMsgBase(ECellLocationResponse, sizeof(TLbsCellLocationResponseMsg), aSessionId) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(TLbsCellLocationResponseMsg) <= KMaximumMessageSizeBytes); iReason = aReason; // Check that the type of aPosInfo is valid TUint32 type = aPosInfo.PositionClassType(); if (((type & EPositionInfoUnknownClass) != EPositionInfoUnknownClass) && ((type & EPositionInfoClass) != EPositionInfoClass) && ((type & EPositionCourseInfoClass) != EPositionCourseInfoClass) && ((type & EPositionSatelliteInfoClass) != EPositionSatelliteInfoClass) && ((type & EPositionExtendedSatelliteInfoClass) != EPositionExtendedSatelliteInfoClass)) { User::Panic(_L("LbsNetInternal"), 1); } // The TPositionInfoBase is just the base class, so we need to copy over // the data from the actual concrete class type. __ASSERT_DEBUG(aPosInfo.PositionClassSize() <= sizeof(TPositionExtendedSatelliteInfo), User::Invariant()); Mem::Copy(&iPosInfo, &aPosInfo, aPosInfo.PositionClassSize()); }
CTRenderOrientation::CTRenderOrientation() { // check that these two enums are aligned __ASSERT_COMPILE(EDisplayOrientationAuto == ENumWindowSets); SetTestStepName(KTRenderOrientation); }
/** Verifies that the buffer contains a structurally correct command. This does not ensure that the content of the command is semantically valid. @param aCommmand A new HL2CapCommand if the buffer contains a structurally valid command. @param aBuffer The buffer containing the command @return KErrNone if the command if created. KErrNoMemory if the command structure is valid but cannot be created. KErrCorrupt if the command structure is invalid. */ TInt HDisconnectRequest::NewCommandIfValid(RMBufChain& aBuffer, HL2CapCommand*& aCommand) { LOG_STATIC_FUNC // Firstly align the MBufChain. The maximum size we can align the // MBufChain to is the maximum MBuf size __ASSERT_COMPILE(KDisconnectRequestLength <= KMBufSmallSize); TInt length = aBuffer.Length(); if(length == KDisconnectRequestLength) { // Don't need to check result as we know that the MBufChain contains // at least length bytes as we asked first. (void)aBuffer.Align(length); aCommand = new HDisconnectRequest(aBuffer); if(aCommand) { return KErrNone; } else { return KErrNoMemory; } } else { // Dodge length! return KErrCorrupt; } }
void CCommSession::AddPlayerToDisconnectList(TWorkerId aPlayerId) { __ASSERT_COMPILE(TC32WorkerThreadPublicInfo::EMaxWorkerThreadId < 32); // Using a TUint32 as a flag container ASSERT(aPlayerId <= TC32WorkerThreadPublicInfo::EMaxWorkerThreadId); __FLOG_STMT( if(!IsPlayerInDisconnectList(aPlayerId)) { C32LOG3(KC32Detail, _L8("CCommSession(%08x):\tAddPlayerToDisconnectList(%d)"), this, aPlayerId ); } )
EXPORT_C TT_LbsAGpsRequestForcedUpdate::TT_LbsAGpsRequestForcedUpdate() : TT_LbsMsgBase(EModuleRequestForcedUpdate) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsRequestForcedUpdate) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsRequestForcedUpdate; ST_LbsAGpsRequestForcedUpdate& data = Data(); }
// // Location Cancel Message from PSY // EXPORT_C TLbsCellLocationCancelMsg::TLbsCellLocationCancelMsg(const TLbsNetSessionIdInt& aSessionId, TInt aReason): TLbsNetInternalMsgBase(ECellLocationCancel, sizeof(TLbsCellLocationCancelMsg), aSessionId) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(TLbsCellLocationCancelMsg) <= KMaximumMessageSizeBytes); iReason = aReason; }
EXPORT_C TLbsNetLocNetworkLocationCompleteMsg::TLbsNetLocNetworkLocationCompleteMsg( const TLbsNetSessionIdInt& aSessionId, TInt aReason) : TLbsNetLocMsgBase(ENetLocMsgNetworkLocationComplete, sizeof(TLbsNetLocNetworkLocationCompleteMsg), aSessionId) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(TLbsNetLocNetworkLocationCompleteMsg) <= KMaximumMessageSizeBytes); iReason = aReason; }
/////////////////////////////////////////////////////////////////////////////// // Test A-Gps Module Request Options /////////////////////////////////////////////////////////////////////////////// EXPORT_C TT_LbsAGpsRequestOptions::TT_LbsAGpsRequestOptions(TLbsHybridModuleOptions aModuleOption) : TT_LbsMsgBase(EModuleRequestOptions) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsRequestOptions) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsRequestOptions; ST_LbsAGpsRequestOptions& data = Data(); data.iModuleOption = aModuleOption; }
// // Location Request Message from PSY // EXPORT_C TLbsCellLocationRequestMsg::TLbsCellLocationRequestMsg(const TLbsNetSessionIdInt& aSessionId, TUid aProtocolModule, const TLbsNetPosRequestOptionsInt& aOptions) : TLbsNetInternalMsgBase(ECellLocationRequest, sizeof(TLbsCellLocationRequestMsg), aSessionId) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(TLbsCellLocationRequestMsg) <= KMaximumMessageSizeBytes); iProtocolModule = aProtocolModule; iOptions = aOptions; }
EXPORT_C TT_LbsAGpsResponseMsg::TT_LbsAGpsResponseMsg(const TModuleResponseType& aResponse) : TT_LbsMsgBase(EModuleResponse) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsResponse) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsResponse; ST_LbsAGpsResponse& data = Data(); data.iResponseType = aResponse; }
/////////////////////////////////////////////////////////////////////////////// // Test A-Gps Module Request Error /////////////////////////////////////////////////////////////////////////////// EXPORT_C TT_LbsAGpsRequestError::TT_LbsAGpsRequestError(TInt aError) : TT_LbsMsgBase(EModuleRequestError) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsRequestError) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsRequestError; ST_LbsAGpsRequestError& data = Data(); data.iError = aError; }
EXPORT_C TT_LbsAGpsRequestTimeOut::TT_LbsAGpsRequestTimeOut(const TTimeIntervalMicroSeconds& aTimeOut) : TT_LbsMsgBase(EModuleRequestTimeOut) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsRequestTimeOut) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsRequestTimeOut; ST_LbsAGpsRequestTimeOut& data = Data(); data.iTimeOut = aTimeOut; }
EXPORT_C void CPolicyServer::ProcessError(const RMessage2& aMsg, TInt aError) { __ASSERT_COMPILE(-1 == RMessage2::EConnect); __ASSERT_ALWAYS(aMsg.Function() >= RMessage2::EConnect, User::Panic(KPolicyServer, 2)); if(aMsg.Authorised() && aMsg.Function() >= 0) { aMsg.Session()->ServiceError(aMsg, aError); } else //Either ServiceL hadn't been called yet (not (yet) authorised) or //it's a Connect message { aMsg.Complete(aError); } }
EXPORT_C TLbsNetLocNetworkLocationRequestMsg::TLbsNetLocNetworkLocationRequestMsg( const TLbsNetSessionIdInt& aSessionId, TBool aNewClient, TLbsNetPosRequestQualityInt aQuality) : TLbsNetLocMsgBase(ENetLocMsgNetworkLocationRequest, sizeof(TLbsNetLocNetworkLocationRequestMsg), aSessionId) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(TLbsNetLocNetworkLocationRequestMsg) <= KMaximumMessageSizeBytes); iNewClient = aNewClient; iQuality = aQuality; }
/////////////////////////////////////////////////////////////////////////////// // Test A-Gps Module Request Update Initialization Message /////////////////////////////////////////////////////////////////////////////// EXPORT_C TT_LbsAGpsRequestUpdateInitMsg::TT_LbsAGpsRequestUpdateInitMsg(const TDesC& aConfigFileName, const TDesC& aConfigSection) : TT_LbsMsgBase(EModuleRequestUpdateInit) { // Must make sure that the data to be stored is not bigger than the buffer. __ASSERT_COMPILE(sizeof(ST_LbsAGpsRequestUpdateInit) <= sizeof(iBuffer)); // In-place construction of the data member new(&Data()) ST_LbsAGpsRequestUpdateInit; ST_LbsAGpsRequestUpdateInit& data = Data(); data.iConfigFileName = aConfigFileName; data.iConfigSection = aConfigSection; }
//static bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) { QFileSystemMetaData meta; QFileSystemEntry absname = absoluteName(entry); fillMetaData(absname, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); if(!(meta.exists() && meta.isDirectory())) return false; RFs& fs = qt_s60GetRFs(); QString abspath = absname.nativeFilePath(); if(!abspath.endsWith(QLatin1Char('\\'))) abspath.append(QLatin1Char('\\')); TInt r = fs.SetSessionPath(qt_QString2TPtrC(abspath)); //SetSessionPath succeeds for non existent directory, which is why it's checked above if (r == KErrNone) { __ASSERT_COMPILE(sizeof(wchar_t) == sizeof(unsigned short)); //attempt to set open C to the same path r = ::wchdir(reinterpret_cast<const wchar_t *>(absname.filePath().utf16())); if (r < 0) qWarning("failed to sync path to open C"); return true; } return false; }
EXPORT_C void CPolicyServer::RunL() { const RMessage2& msg = Message(); msg.ClearAuthorised(); TInt fn = msg.Function(); __ASSERT_COMPILE(-1 == RMessage2::EConnect); if(fn >= RMessage2::EConnect) //So this implies any "normal" message or Connect //Now we have two steps to follow each having two mutually exculsive //parts. //Step 1: Find policy. //Step 2: Apply policy. { const TPolicyElement* element = 0; TUint specialCase = 0; //1a: If its a normal message. Find the associate policy or special //case action. if(fn >= 0) { element = FindPolicyElement(fn, specialCase); } //1b: If its a connect message, there's a shortcut to the policy. else { TUint8 i = iPolicy.iOnConnect; if(i >= ESpecialCaseHardLimit) specialCase = i; else element = &(iPolicy.iElements[i]); } //2a: We found a policy that we can automatically apply... Apply it! if(element) { TSecurityInfo missing; //If policy check succeeds, allow it through if(element->iPolicy.CheckPolicy(msg, missing, __PSD("Checked by CPolicyServer::RunL"))) { ProcessL(msg); } //Else see what failure action is required (return error code, //panic client, ask user, etc...) else { CheckFailedL(msg, element->iAction, missing); } } //2b: The policy is a special case else { switch(specialCase) { //If you change this you'll have to add to the switch statement __ASSERT_COMPILE(ESpecialCaseLimit == 252u); case ECustomCheck: { TInt action = EFailClient; //The default action after failing a CustomSecurityCheck is //to complete the message with KErrPermissionDenied. If //you want a different action, then change the action //parameter prior to returning from your derived //implementation of CustomSecurityCheckL TSecurityInfo missing; __ASSERT_COMPILE(SCapabilitySet::ENCapW == 2); memset(&missing, 0, sizeof(SSecurityInfo)); TCustomResult result = CustomSecurityCheckL(msg, action, missing); if(result == EPass) { ProcessL(msg); } else if(result == EFail) { CheckFailedL(msg, action, missing); } else if(result == EAsync) { //Do Nothing. Derived CustomSecurityCheck is //responsible for calling ProcessL/CheckFailedL } else Panic(EPolSvrInvalidCustomResult); } break; case ENotSupported: msg.Complete(KErrNotSupported); break; case EAlwaysPass: ProcessL(msg); break; default: Panic(EPolSvrPolicyInvalid); break; } } } //else it must be either Disconnect or bad message. Both are handled by //ProcessL else { ProcessL(msg); } // Queue reception of next message if it hasn't already been done if(!IsActive()) ReStart(); }
/** Open a drive for formatting. */ TInt FsFormatOpen(CFsRequest* aRequest) { TDrive& drive = *aRequest->Drive(); __PRINT1(_L("FsFormatOpen() drv:%d"), drive.DriveNumber()); TInt nMountRes = drive.CheckMount(); //-- KErrNotReady means that there is no file system mounted on this drive //-- KErrInUse means that there are some "disk access" objects, like RFormat or RRawDisk opened on the mount. if(nMountRes == KErrNotReady || nMountRes == KErrInUse) { __PRINT1(_L("FsFormatOpen() ChkMount:%d"), nMountRes); return nMountRes; } const TFormatMode fmtMode = (TFormatMode)aRequest->Message().Int1(); TName buf; TUint32 currFsNameHash = 0; //-- current file system name hash, 0 means "not set"; used during forced FS dismounting if((nMountRes == KErrNone) && drive.CurrentMount().LockStatus() < 0) {//-- the mount is locked, it has normal objects (files, directories) opened on it. //-- if someone is interested in the list of opened files and number of opened directories, compile this code in. #ifdef DUMP_OPENED_OBJECTS DumpOpenedObjects(drive); #endif //DUMP_OPENED_OBJECTS if(!(fmtMode & EForceFormat)) { __PRINT(_L("FsFormatOpen() The mount is in use")); return KErrInUse; } //-- there is a special flag that tells to force media dismounting even if it has files or dirs opened. __PRINT(_L("FsFormatOpen() The mount is in use, forcing dismounting!")); //-- record currently mounted FS name hash, it may be used after forced dismounting drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive currFsNameHash = TVolFormatParam::CalcFSNameHash(buf); //-- kill the current mount FsThreadManager::LockDrive(drive.DriveNumber()); TInt nRes = drive.ForceUnmountFileSystemForFormatting(); FsThreadManager::UnlockDrive(drive.DriveNumber()); switch(nRes) { case KErrInUse: __PRINT(_L("FsFormatOpen() The mount has clamps! Can't force dismount")); return KErrInUse; //-- there are clamps on this drive - can't dismount case KErrNone: break; default: ASSERT(0); //-- unexpected error code return nRes; }; if(fmtMode & EQuickFormat) {//-- quick format may require the normally mounted FS, make the best effrot to mount it nMountRes = drive.CheckMount(); } else {//-- this will make the FS mounted by force; for full format it will be quicker nMountRes = KErrCorrupt; } } //-- if True, we will need mount (probably specific) file system by force because normal mounting has failed TBool bNeedForceMount = (nMountRes != KErrNone); //-- find out if we have optional data structure that describes format parameter TUint32 newFsNameHash = 0; //-- file system name hash, may be used for selecting which file system to put onto the volume. 0 means "not specified" const TLDFormatInfo* pLDFormatInfo = NULL; const TVolFormatParam* pVolFormatParam = NULL; __ASSERT_COMPILE(sizeof(TVolFormatParam) >= sizeof(TLDFormatInfo)); TBuf8<sizeof(TVolFormatParam)> paramBuf; if(fmtMode & ESpecialFormat) { //-- the user has provided format parameters structure. //-- IPC argument #2 contains a structure: <TUint32>[optional package descriptor] //-- 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 const TInt desLen = aRequest->GetDesLength(KMsgPtr2); ASSERT((TUint32)desLen >= sizeof(TUint32)); const TInt dataPckgLen = desLen - sizeof(TUint32); if((TUint32)dataPckgLen > sizeof(TUint32)) { aRequest->ReadL(KMsgPtr2, paramBuf); } if(dataPckgLen == sizeof(TLDFormatInfo)) {//-- the user has provided formatting parameters via TLDFormatInfo structure. pLDFormatInfo = (const TLDFormatInfo*)(paramBuf.Ptr() + sizeof(TUint32)); } else if(dataPckgLen == sizeof(TVolFormatParam)) {//-- it's likely to be TVolFormatParam, need to check UId to be sure. pVolFormatParam = (const TVolFormatParam*)(const TVolFormatParam*)(paramBuf.Ptr() + sizeof(TUint32)); if(pVolFormatParam->iUId == TVolFormatParam::KUId) //-- check the class UID {//-- this is the real TVolFormatParam object passed newFsNameHash = pVolFormatParam->FSNameHash(); } } else if(dataPckgLen >0) {//-- parameters data structure has strange length return KErrArgument; } } //------------------- if(!newFsNameHash && currFsNameHash) {//-- new file system name isn't specified (default formatting), but the volume had been forcedly dismounted. //-- restore the original file system newFsNameHash = currFsNameHash; } if(newFsNameHash) {//-- check if the specified FS is already mounted on the volume if(!bNeedForceMount) { drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive } else { //-- the iCurrentMount can be NULL, use the iFsys - the real file system associated with this drive buf = drive.GetFSys()->Name(); } const TUint32 currFSNameHash = TVolFormatParam::CalcFSNameHash(buf); if(currFSNameHash == newFsNameHash) {//-- no need to do anything, the required FS is already mounted newFsNameHash = 0; } } if(newFsNameHash) { //-- the user has specified some filesystem to be mounted on the volume. Check if this FS is supported at all. //-- if it is supported, but some other FS is currently mounted, it will be dismounted and the new one will be forced. TInt nRes; for(TInt cntFS=0; ;++cntFS) { nRes = drive.FSys().GetSupportedFileSystemName(cntFS, buf); //-- enumerate possible child file systems if(nRes != KErrNone) return KErrNotSupported; //-- the filesystem with the given name (fsNameHash) is not supported. if(newFsNameHash == TVolFormatParam::CalcFSNameHash(buf)) {//-- the filesystem with the given name (fsNameHash) is supported, but some other filesystem can be already mounted drive.Dismount(); bNeedForceMount = ETrue; //-- this will force the desired FS to be mounted break; } } }//if(fsNameHash) //-- try force mounting the desired file system if it is required if(bNeedForceMount) { const TInt KMaxRetries = 3; for(TInt cnt=0; ; ++cnt) { drive.MountFileSystem(ETrue, newFsNameHash); nMountRes = drive.GetReason(); if(nMountRes == KErrNone || nMountRes == KErrLocked) break; drive.Dismount(); //-- will reset mount retries counter if(cnt >= KMaxRetries) { __PRINT1(_L("FsFormatOpen() can't mount FS! res:%d"), nMountRes); return nMountRes; } } } ASSERT(nMountRes == KErrNone || nMountRes == KErrLocked); __ASSERT_DEBUG(drive.CurrentMount().LockStatus()==0, Fault(ESvrFormatOpenFailed)); TDriveInfo dInfo; drive.DriveInfo(dInfo); const TInt mediaAtt = dInfo.iMediaAtt; #if defined(_LOCKABLE_MEDIA) if (!(fmtMode & EForceErase) && (mediaAtt & KMediaAttLocked)) { // if attempting to format a locked drive, dismount otherwise subsequent // requests will operate on a mount that has been forcibly mounted (a few lines above) CMountCB* pM = &drive.CurrentMount(); if(pM) pM->Close(); drive.MountFileSystem(EFalse); // clear iCurrentMount return KErrLocked; } #endif if (!(mediaAtt & KMediaAttFormattable) || (mediaAtt & KMediaAttWriteProtected)) { CMountCB* pM = &drive.CurrentMount(); if(pM) pM->Close(); drive.MountFileSystem(EFalse); return KErrAccessDenied; } //-- instantinate and open CFormatCB object for this drive CFormatCB* formatCB=NULL; TInt fmtHandle; TRAPD(ret, formatCB = drive.FormatOpenL(aRequest, fmtHandle, fmtMode, pLDFormatInfo, pVolFormatParam )); if (ret!=KErrNone) { if(formatCB) formatCB->Close(); return ret; } TPtrC8 pH((TUint8*)&fmtHandle,sizeof(TInt)); aRequest->WriteL(KMsgPtr3,pH); TInt count=100; TPtrC8 pCount((TUint8*)&count,sizeof(TInt)); aRequest->WriteL(KMsgPtr2,pCount); aRequest->Session()->IncResourceCount(); return KErrNone; }
void CMemSpyEngineHelperActiveObject::ExtractActiveObjectAddressesL( TAny* aSchedulerCellAddress, const TDesC8& aSchedulerCellData, CMemSpyEngineActiveObjectArray& aArray ) { // Create read stream RDesReadStream stream( aSchedulerCellData ); CleanupClosePushL( stream ); // First item is vtable TUint address = stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ExtractActiveObjectAddressesL() - vtable: 0x%08x", address ); (void) address; // Next item is CActiveScheduler::iStack - which we'll skip, because it might be a stack address // I suppose we could validate this against the thread's stack address range, but can't be bothered // at the moment. address = stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ExtractActiveObjectAddressesL() - got CActiveScheduler::iStack as: 0x%08x", address); (void) address; // Then comes CActiveScheduler::iActiveQ - this is what we are interested in.... // // class TPriQue : public TDblQueBase // [TDblQueBase::iHead] - this just derives from TDblQueLinkBase and doesn't have any direct data members // class TDblQueLink : public TDblQueLinkBase // [ptr] TDblQueLinkBase::iNext* // [ptr] TDblQueLinkBase::iPrev* // [TInt] TDblQueBase::iOffset __ASSERT_COMPILE( sizeof( TDblQueLinkBase* ) == sizeof(TUint) ); __ASSERT_COMPILE( sizeof( TInt ) == 4 ); // Get read offset so that we know the starting address of the queue const TStreamPos pos = stream.Source()->TellL(MStreamBuf::ERead); #ifdef __WINS__ const TAny* terminatingQueueAddress = (TAny*) (TUint(aSchedulerCellAddress) + pos.Offset()); #else const TAny* terminatingQueueAddress = (TAny*) aSchedulerCellAddress; #endif const TAny* queueNext = (TAny*) stream.ReadUint32L(); const TAny* queuePrev = (TAny*) stream.ReadUint32L(); const TUint queueItemOffset = stream.ReadUint32L(); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ExtractActiveObjectAddressesL() - queueNext: 0x%08x, queuePrev: 0x%08x, queueItemOffset: %d, pos: %d, terminatingQueueAddress: 0x%08x", queueNext, queuePrev, queueItemOffset, pos.Offset(), terminatingQueueAddress); (void) queuePrev; CleanupStack::PopAndDestroy( &stream ); // Iterate through the active objects if ( queueNext != NULL ) { TAny* realNextCellHeapCell = NULL; TAny* calculatedCellAddress = ((TAny*) (TUint(queueNext) - queueItemOffset)); while( !( calculatedCellAddress == NULL || calculatedCellAddress == terminatingQueueAddress || realNextCellHeapCell == terminatingQueueAddress ) ) { // Create an active object for this cell TAny* nextCell = ReadActiveObjectDataL( calculatedCellAddress, aArray ); // Work out next cell address calculatedCellAddress = ((TAny*) ( TUint( nextCell ) - queueItemOffset ) ); //RDebug::Printf("CMemSpyEngineHelperActiveObject::ExtractActiveObjectAddressesL() - calculatedCellAddress: 0x%08x, terminatingQueueAddress: 0x%08x", calculatedCellAddress, terminatingQueueAddress); // Identify the next cell address realNextCellHeapCell = ConvertAddressToRealHeapCellAddressL( nextCell ); } } }
EXPORT_C TT_LbsMsgBase::TT_LbsMsgBase() : iType(EUnknown) { // Check that the internal buffer is 8-byte aligned. __ASSERT_COMPILE((_FOFF(TT_LbsMsgBase, iBuffer) & 0x40) == 0x0); }