vold: Allow creation of a container with no filesystem

Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
San Mehat 2010-02-28 20:17:20 -08:00
parent 55013f7131
commit a1091cb0c4

View file

@ -219,22 +219,13 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
strcpy(dmDevice, loopDevice); strcpy(dmDevice, loopDevice);
} }
if (Fat::format(dmDevice)) { if (strcmp(fstype, "none")) {
LOGE("ASEC FAT format failed (%s)", strerror(errno)); if (strcmp(fstype, "fat")) {
if (cleanupDm) { LOGW("Unknown fstype '%s' specified for container", fstype);
Devmapper::destroy(id);
} }
Loop::destroyByDevice(loopDevice);
unlink(asecFileName);
return -1;
}
char mountPoint[255]; if (Fat::format(dmDevice)) {
LOGE("ASEC FAT format failed (%s)", strerror(errno));
snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
if (mkdir(mountPoint, 0777)) {
if (errno != EEXIST) {
LOGE("Mountpoint creation failed (%s)", strerror(errno));
if (cleanupDm) { if (cleanupDm) {
Devmapper::destroy(id); Devmapper::destroy(id);
} }
@ -242,18 +233,33 @@ int VolumeManager::createAsec(const char *id, unsigned int numSectors,
unlink(asecFileName); unlink(asecFileName);
return -1; return -1;
} }
} char mountPoint[255];
if (Fat::doMount(dmDevice, mountPoint, false, false, ownerUid, snprintf(mountPoint, sizeof(mountPoint), "%s/%s", Volume::ASECDIR, id);
0, 0000, false)) { if (mkdir(mountPoint, 0777)) {
// 0, 0007, false)) { if (errno != EEXIST) {
LOGE("ASEC FAT mount failed (%s)", strerror(errno)); LOGE("Mountpoint creation failed (%s)", strerror(errno));
if (cleanupDm) { if (cleanupDm) {
Devmapper::destroy(id); Devmapper::destroy(id);
}
Loop::destroyByDevice(loopDevice);
unlink(asecFileName);
return -1;
}
} }
Loop::destroyByDevice(loopDevice);
unlink(asecFileName); if (Fat::doMount(dmDevice, mountPoint, false, false, ownerUid,
return -1; 0, 0000, false)) {
LOGE("ASEC FAT mount failed (%s)", strerror(errno));
if (cleanupDm) {
Devmapper::destroy(id);
}
Loop::destroyByDevice(loopDevice);
unlink(asecFileName);
return -1;
}
} else {
LOGI("Created raw secure container %s (no filesystem)", id);
} }
mActiveContainers->push_back(strdup(id)); mActiveContainers->push_back(strdup(id));