am cbacf78e: Track type of container mounted

Merge commit 'cbacf78eff70bd43bb899e164ec2ab409bc0904c' into gingerbread-plus-aosp

* commit 'cbacf78eff70bd43bb899e164ec2ab409bc0904c':
  Track type of container mounted
gugelfrei
Kenny Root 14 years ago committed by Android Git Automerger
commit 45f22ad121

@ -445,7 +445,7 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
SLOGI("Created raw secure container %s (no filesystem)", id);
}
mActiveContainers->push_back(strdup(id));
mActiveContainers->push_back(new ContainerData(strdup(id), ASEC));
return 0;
}
@ -624,7 +624,8 @@ int VolumeManager::unmountLoopImage(const char *id, const char *idHash,
AsecIdCollection::iterator it;
for (it = mActiveContainers->begin(); it != mActiveContainers->end(); ++it) {
if (!strcmp(*it, id)) {
ContainerData* cd = *it;
if (!strcmp(cd->id, id)) {
free(*it);
mActiveContainers->erase(it);
break;
@ -790,7 +791,7 @@ int VolumeManager::mountAsec(const char *id, const char *key, int ownerUid) {
return -1;
}
mActiveContainers->push_back(strdup(id));
mActiveContainers->push_back(new ContainerData(strdup(id), ASEC));
if (mDebug) {
SLOGD("ASEC %s mounted", id);
}
@ -894,7 +895,7 @@ int VolumeManager::mountObb(const char *img, const char *key, int ownerUid) {
return -1;
}
mActiveContainers->push_back(strdup(img));
mActiveContainers->push_back(new ContainerData(strdup(img), OBB));
if (mDebug) {
SLOGD("Image %s mounted", img);
}
@ -1174,9 +1175,20 @@ bool VolumeManager::isMountpointMounted(const char *mp)
int VolumeManager::cleanupAsec(Volume *v, bool force) {
while(mActiveContainers->size()) {
AsecIdCollection::iterator it = mActiveContainers->begin();
SLOGI("Unmounting ASEC %s (dependant on %s)", *it, v->getMountpoint());
if (unmountAsec(*it, force)) {
SLOGE("Failed to unmount ASEC %s (%s)", *it, strerror(errno));
ContainerData* cd = *it;
SLOGI("Unmounting ASEC %s (dependant on %s)", cd->id, v->getMountpoint());
if (cd->type == ASEC) {
if (unmountAsec(cd->id, force)) {
SLOGE("Failed to unmount ASEC %s (%s)", cd->id, strerror(errno));
return -1;
}
} else if (cd->type == OBB) {
if (unmountObb(cd->id, force)) {
SLOGE("Failed to unmount OBB %s (%s)", cd->id, strerror(errno));
return -1;
}
} else {
SLOGE("Unknown container type %d!", cd->type);
return -1;
}
}

@ -27,7 +27,27 @@
/* The length of an MD5 hash when encoded into ASCII hex characters */
#define MD5_ASCII_LENGTH_PLUS_NULL ((MD5_DIGEST_LENGTH*2)+1)
typedef android::List<char *> AsecIdCollection;
typedef enum { ASEC, OBB } container_type_t;
class ContainerData {
public:
ContainerData(char* _id, container_type_t _type)
: id(_id)
, type(_type)
{}
~ContainerData() {
if (id != NULL) {
free(id);
id = NULL;
}
}
char *id;
container_type_t type;
};
typedef android::List<ContainerData*> AsecIdCollection;
class VolumeManager {
private:

Loading…
Cancel
Save