More fixes for internal FAT partitions:

Fix formatting partitions beyond the first partition.
Do not try to initialize the MBR when formatting only a single partition.

Change-Id: Ifbbd279b1c288b7b1b884a1a89248e3086ed735f
Signed-off-by: Mike Lockwood <lockwood@android.com>
gugelfrei
Mike Lockwood 14 years ago
parent 1b15d463d4
commit a4886f1f8e

@ -30,7 +30,6 @@ public:
static const int MAX_PARTITIONS = 4;
protected:
PathCollection *mPaths;
int mPartIdx;
int mDiskMajor;
int mDiskMinor;
int mPartMinors[MAX_PARTITIONS];

@ -110,6 +110,7 @@ Volume::Volume(VolumeManager *vm, const char *label, const char *mount_point) {
mMountpoint = strdup(mount_point);
mState = Volume::State_Init;
mCurrentlyMountedKdev = -1;
mPartIdx = -1;
}
Volume::~Volume() {
@ -210,28 +211,31 @@ int Volume::formatVol() {
return -1;
}
bool formatEntireDevice = (mPartIdx == -1);
char devicePath[255];
dev_t diskNode = getDiskDevice();
dev_t partNode = MKDEV(MAJOR(diskNode), 1); // XXX: Hmmm
dev_t partNode = MKDEV(MAJOR(diskNode), (formatEntireDevice ? 1 : mPartIdx));
sprintf(devicePath, "/dev/block/vold/%d:%d",
MAJOR(diskNode), MINOR(diskNode));
if (mDebug) {
SLOGI("Formatting volume %s (%s)", getLabel(), devicePath);
}
setState(Volume::State_Formatting);
if (initializeMbr(devicePath)) {
SLOGE("Failed to initialize MBR (%s)", strerror(errno));
// goto err;
// don't treat this as a fatal error
// lets continue on and format the partition
// Only initialize the MBR if we are formatting the entire device
if (formatEntireDevice) {
sprintf(devicePath, "/dev/block/vold/%d:%d",
MAJOR(diskNode), MINOR(diskNode));
if (initializeMbr(devicePath)) {
SLOGE("Failed to initialize MBR (%s)", strerror(errno));
goto err;
}
}
sprintf(devicePath, "/dev/block/vold/%d:%d",
MAJOR(partNode), MINOR(partNode));
if (mDebug) {
SLOGI("Formatting volume %s (%s)", getLabel(), devicePath);
}
if (Fat::format(devicePath, 0)) {
SLOGE("Failed to format (%s)", strerror(errno));
goto err;
@ -582,7 +586,6 @@ out_nomedia:
setState(Volume::State_NoMedia);
return -1;
}
int Volume::initializeMbr(const char *deviceNode) {
struct disk_info dinfo;

@ -51,6 +51,7 @@ protected:
char *mMountpoint;
VolumeManager *mVm;
bool mDebug;
int mPartIdx;
/*
* The major/minor tuple of the currently mounted filesystem.

Loading…
Cancel
Save