×
Namespaces

Variants
Actions

Archived:Programmatic formatting of the memory card (E:) fails with KErrInUse (Known Issue)

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Formatting a memory card using RFormat API's Format function fails with KErrInUse in some S60 3rd Edition, FP1 devices. The reason for this could be an application constantly trying to access the memory card.

Article Metadata
Tested with
Devices(s): Nokia N95, Nokia N82
Compatibility
Platform(s): S60 3rd Editon FP1
S60 3rd Edition FP1
Article
Created: User:Technical writer 1 (03 Sep 2008)
Last edited: hamishwillee (14 Jun 2013)

How to reproduce

The following code fails in the Nokia N95 and the Nokia N82 with KErrInUse.

 _LIT(KDriveE,"E:");
RFs fs;
User::LeaveIfError(fs.Connect());
RFormat format;
TInt tracksRemaining;
User::LeaveIfError(format.Open(fs,KDriveE,EHighDensity,tracksRemaining));
while (tracksRemaining)
{
User::LeaveIfError(format.Next(tracksRemaining));
}
format.Close();

Solution

To ensure that no other application is accessing the memory card, dismount the memory card and remount it after a while (1 second) before formatting it.

 _LIT(KDriveE,"E:");
_LIT( KFSName, "Fat" );
RFs fs;
RFormat format;
TInt tracksRemaining;
TRequestStatus stat;
User::LeaveIfError(fs.Connect());
fs.NotifyDismount(EDriveE, stat, EFsDismountForceDismount);//Dismount the drive
User::WaitForRequest(stat);
User::After(1000000); //we have to wait until clients have received notification about card dismount
fs.MountFileSystem(KFSName,EDriveE);//Mount drive back in
User::LeaveIfError(format.Open(fs,KDriveE,EHighDensity,tracksRemaining));
while (tracksRemaining)
{
User::LeaveIfError(format.Next(tracksRemaining));
}
format.Close();
This page was last modified on 14 June 2013, at 08:50.
47 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×