Fixed lots of issues with installing a low-caps version of fshell from SIS file.
* Fixed issue in CCommandFactory whereby some APIs like GetCommandInfoL could trigger allocations on the wrong heap or signals to the wrong thread. The symptoms were often seen as a crash in the which_00 thread when running ciftest.
* Lots of build fixes for when FSHELL_PROTECTED_UIDS isn't defined and when all capabilities aren't available.
* Added new platform.mmh macro FSHELL_OPEN_SIGNED.
* Open signing of fshell SIS files is now supported for production S60 handsets. Build fshell with the FSHELL_OPEN_SIGNED macro defined (and without defining FSHELL_CAP_ALL or FSHELL_PROTECTED_UIDS) in your platform.mmh and submit \epoc32\fshell\fshell.unsigned.sis to https://www.symbiansigned.com/app/page/public/openSignedOnline.do . The following commands are not available when using Open Signing due to Platform Security restrictions: fdb; kerninfo; chunkinfo; svrinfo; objinfo; sudo; fsck; localdrive; ramdefrag; readmem; reboot; setcritical; setpriority. Others such as chkdeps, e32header, ps, and fshell itself will run but in a restricted capacity (for example, fshell will no longer allow you to modify files in the \sys\bin directory).
* Removed commands objinfo, svrinfo, chunkinfo, readmem, fsck completely when memory access isn't present - previously they would still appear in the help but would give an error if you tried to run them.
// backup.cpp
//
// Copyright (c) 2008 - 2010 Accenture. All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Accenture - Initial contribution
//
#include "backup.h"
_LIT(KBackupOp, "-b");
//
// CBackupDriver
//
CBackupDriver* CBackupDriver::NewL(MBackupParent& aParent)
{
CBackupDriver* self = new (ELeave) CBackupDriver(aParent);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
CBackupDriver::CBackupDriver(MBackupParent& aParent):
CActive(CActive::EPriorityStandard), iParent(aParent)
{
CActiveScheduler::Add(this);
}
CBackupDriver::~CBackupDriver()
{
Cancel();
}
void CBackupDriver::ConstructL()
{
}
void CBackupDriver::SendInstructionL(MBackupObserver::TFileLockFlags aInstruction)
{
iInstruction = aInstruction;
switch (iInstruction)
{
case MBackupObserver::EReleaseLockNoAccess:
LaunchProcessL();
break;
case MBackupObserver::ETakeLock:
TerminateProcessL();
break;
default:
User::Leave(KErrNotSupported);
break;
};
}
//
// CBackupDriver::ChildProcessExists
// checks whether the backup_child process
// is already running
//
TBool CBackupDriver::ChildProcessExists()
{
_LIT(KWildCard, "*");
TName woop(KBackupProcessName);
woop.Append(KWildCard);
TFindProcess check(woop);
TFullName name;
TInt result = check.Next(name);
if (result == KErrNone)
return ETrue;
return EFalse;
}
//
// CBackupDriver::LaunchProcessL
// spawns the backup_child process
// & waits to rendezvous
//
void CBackupDriver::LaunchProcessL()
{
if (ChildProcessExists())
User::Leave(KErrInUse);
_LIT(KExeExt, ".exe");
TName name(KBackupProcessName);
name.Append(KExeExt);
User::LeaveIfError(iChild.Create(name, KBackupOp, EOwnerProcess));
iChild.Resume();
iChild.Rendezvous(iStatus);
SetActive();
}
//
// CBackupDriver::TerminateProcessL
// open the backup_child process & signal it's semaphore
// that semaphore is the signal to shut itself down cleanly
//
void CBackupDriver::TerminateProcessL()
{
if (!ChildProcessExists())
User::Leave(KErrNotFound);
// signal the semaphore
RSemaphore sem;
User::LeaveIfError(sem.OpenGlobal(KBackupSemaphore, EOwnerProcess));
sem.Signal();
SelfComplete(KErrNone);
}
void CBackupDriver::SelfComplete(const TInt aError)
{
ASSERT(!IsActive());
iStatus = KRequestPending;
TRequestStatus* status = &iStatus;
User::RequestComplete(status, aError);
SetActive();
}
//
// CBackupDriver::RunL
//
void CBackupDriver::RunL()
{
iParent.Finished(iStatus.Int());
}
//
// CBackupDriver::DoCancel
//
void CBackupDriver::DoCancel()
{
ASSERT(EFalse); // not dealing with this!
}
//
// CCmdBackup
//
CCommandBase* CCmdBackup::NewLC()
{
CCmdBackup* self = new (ELeave) CCmdBackup();
CleanupStack::PushL(self);
self->BaseConstructL();
return self;
}
CCmdBackup::~CCmdBackup()
{
delete iBackup;
}
CCmdBackup::CCmdBackup() :
CCommandBase(CCommandBase::EManualComplete)
{
}
const TDesC& CCmdBackup::Name() const
{
_LIT(KName, "backup");
return KName;
}
void CCmdBackup::DoRunL()
{
// spawn the stuff I need to do the task
iBackup = CBackupDriver::NewL(*this);
// process the argument
MBackupObserver::TFileLockFlags flag = MBackupObserver::EReleaseLockNoAccess;
switch (iOperation)
{
case EStart:
flag = MBackupObserver::EReleaseLockNoAccess;
break;
case EStop:
flag = MBackupObserver::ETakeLock;
break;
default:
User::LeaveIfError(KErrArgument);
}
// send the instruction through
iBackup->SendInstructionL(flag);
}
void CCmdBackup::ArgumentsL(RCommandArgumentList& aArguments)
{
_LIT(KArgOperation, "operation");
aArguments.AppendEnumL((TInt&)iOperation, KArgOperation);
}
void CCmdBackup::Finished(const TInt aError)
{
Complete(aError);
}
EXE_BOILER_PLATE(CCmdBackup)