summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-11-18 19:43:45 -0800
committerSteve Kondik <shade@chemlab.org>2012-11-18 19:43:45 -0800
commit57e08d0966a86b8d42378e5d2e5f8c9a756b6da0 (patch)
treeef80850c3084526afbacf996e0b819110d76c0e1
parent3e61f1d12494ac0f456623681f12edf9b356245f (diff)
parent1cbe0ce40c523de48911fec2a94aec34e8ab14a3 (diff)
downloadsystem_vold-57e08d0966a86b8d42378e5d2e5f8c9a756b6da0.zip
system_vold-57e08d0966a86b8d42378e5d2e5f8c9a756b6da0.tar.gz
system_vold-57e08d0966a86b8d42378e5d2e5f8c9a756b6da0.tar.bz2
Merge branch 'jb-mr1-release' of https://android.googlesource.com/platform/system/vold into mr1
Conflicts: Volume.cpp Change-Id: I0b28a56ac2edf1807ee21d23058bcfc5b4bb7724
-rw-r--r--CommandListener.cpp2
-rw-r--r--DirectVolume.cpp22
-rw-r--r--Volume.cpp45
-rw-r--r--VolumeManager.cpp4
-rw-r--r--cryptfs.c45
5 files changed, 70 insertions, 48 deletions
diff --git a/CommandListener.cpp b/CommandListener.cpp
index dff4625..461103e 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -447,7 +447,7 @@ int CommandListener::ObbCmd::runCommand(SocketClient *cli,
dumpArgs(argc, argv, 3);
if (argc != 5) {
cli->sendMsg(ResponseCode::CommandSyntaxError,
- "Usage: obb mount <filename> <key> <ownerUid>", false);
+ "Usage: obb mount <filename> <key> <ownerGid>", false);
return 0;
}
rc = vm->mountObb(argv[2], argv[3], atoi(argv[4]));
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index e463446..3b8c08d 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -121,6 +121,16 @@ int DirectVolume::handleBlockEvent(NetlinkEvent *evt) {
} else {
handlePartitionAdded(dp, evt);
}
+ /* Send notification iff disk is ready (ie all partitions found) */
+ if (getState() == Volume::State_Idle) {
+ char msg[255];
+
+ snprintf(msg, sizeof(msg),
+ "Volume %s %s disk inserted (%d:%d)", getLabel(),
+ getMountpoint(), mDiskMajor, mDiskMinor);
+ mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskInserted,
+ msg, false);
+ }
} else if (action == NetlinkEvent::NlActionRemove) {
if (!strcmp(devtype, "disk")) {
handleDiskRemoved(dp, evt);
@@ -156,8 +166,6 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
mDiskNumParts = 1;
}
- char msg[255];
-
int partmask = 0;
int i;
for (i = 1; i <= mDiskNumParts; i++) {
@@ -177,11 +185,6 @@ void DirectVolume::handleDiskAdded(const char *devpath, NetlinkEvent *evt) {
#endif
setState(Volume::State_Pending);
}
-
- snprintf(msg, sizeof(msg), "Volume %s %s disk inserted (%d:%d)",
- getLabel(), getMountpoint(), mDiskMajor, mDiskMinor);
- mVm->getBroadcaster()->sendBroadcast(ResponseCode::VolumeDiskInserted,
- msg, false);
}
void DirectVolume::handlePartitionAdded(const char *devpath, NetlinkEvent *evt) {
@@ -292,6 +295,11 @@ void DirectVolume::handleDiskRemoved(const char *devpath, NetlinkEvent *evt) {
int major = atoi(evt->findParam("MAJOR"));
int minor = atoi(evt->findParam("MINOR"));
char msg[255];
+ bool enabled;
+
+ if (mVm->shareEnabled(getLabel(), "ums", &enabled) == 0 && enabled) {
+ mVm->unshareVolume(getLabel(), "ums");
+ }
SLOGD("Volume %s %s disk %d:%d removed\n", getLabel(), getMountpoint(), major, minor);
snprintf(msg, sizeof(msg), "Volume %s %s disk removed (%d:%d)",
diff --git a/Volume.cpp b/Volume.cpp
index 0e4f277..6d9f7e4 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -658,44 +658,29 @@ int Volume::unmountVol(bool force, bool revert) {
usleep(1000 * 1000); // Give the framework some time to react
/*
- * First move the mountpoint back to our internal staging point
- * so nobody else can muck with it while we work.
+ * Remove the bindmount we were using to keep a reference to
+ * the previously obscured directory.
*/
- if (doMoveMount(getMountpoint(), SEC_STGDIR, force)) {
- SLOGE("Failed to move mount %s => %s (%s)", getMountpoint(), SEC_STGDIR, strerror(errno));
- setState(Volume::State_Mounted);
- return -1;
+ if (doUnmount(Volume::SEC_ASECDIR_EXT, force)) {
+ SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR_EXT, strerror(errno));
+ goto fail_remount_tmpfs;
}
- protectFromAutorunStupidity();
-
- /* Undo createBindMounts(), which is only called for primary storage */
- if (isPrimaryStorage()) {
- /*
- * Unmount the tmpfs which was obscuring the asec image directory
- * from non root users
- */
-
- if (doUnmount(Volume::SEC_STG_SECIMGDIR, force)) {
- SLOGE("Failed to unmount tmpfs on %s (%s)", SEC_STG_SECIMGDIR, strerror(errno));
- goto fail_republish;
- }
-
- /*
- * Remove the bindmount we were using to keep a reference to
- * the previously obscured directory.
- */
-
- if (doUnmount(Volume::SEC_ASECDIR_EXT, force)) {
- SLOGE("Failed to remove bindmount on %s (%s)", SEC_ASECDIR_EXT, strerror(errno));
- goto fail_remount_tmpfs;
- }
+ /*
+ * Unmount the tmpfs which was obscuring the asec image directory
+ * from non root users
+ */
+ char secure_dir[PATH_MAX];
+ snprintf(secure_dir, PATH_MAX, "%s/.android_secure", getMountpoint());
+ if (doUnmount(secure_dir, force)) {
+ SLOGE("Failed to unmount tmpfs on %s (%s)", secure_dir, strerror(errno));
+ goto fail_republish;
}
/*
* Finally, unmount the actual block device from the staging dir
*/
- if (doUnmount(Volume::SEC_STGDIR, force)) {
+ if (doUnmount(getMountpoint(), force)) {
SLOGE("Failed to unmount %s (%s)", SEC_STGDIR, strerror(errno));
goto fail_recreate_bindmount;
}
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 040e95c..a944543 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -1005,7 +1005,7 @@ Volume* VolumeManager::getVolumeForFile(const char *fileName) {
/**
* Mounts an image file <code>img</code>.
*/
-int VolumeManager::mountObb(const char *img, const char *key, int ownerUid) {
+int VolumeManager::mountObb(const char *img, const char *key, int ownerGid) {
char mountPoint[255];
char idHash[33];
@@ -1089,7 +1089,7 @@ int VolumeManager::mountObb(const char *img, const char *key, int ownerUid) {
}
}
- if (Fat::doMount(dmDevice, mountPoint, true, false, true, ownerUid, 0,
+ if (Fat::doMount(dmDevice, mountPoint, true, false, true, 0, ownerGid,
0227, false)) {
SLOGE("Image mount failed (%s)", strerror(errno));
if (cleanupDm) {
diff --git a/cryptfs.c b/cryptfs.c
index e1c177d..bcacc39 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -59,6 +59,8 @@
#define EXT4_FS 1
#define FAT_FS 2
+#define TABLE_LOAD_RETRIES 10
+
char *me = "cryptfs";
static unsigned char saved_master_key[KEY_LEN_BYTES];
@@ -385,6 +387,7 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
struct dm_target_spec *tgt;
unsigned int minor;
int fd;
+ int i;
int retval = -1;
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
@@ -427,9 +430,18 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
crypt_params = (char *) (((unsigned long)crypt_params + 7) & ~8); /* Align to an 8 byte boundary */
tgt->next = crypt_params - buffer;
- if (ioctl(fd, DM_TABLE_LOAD, io)) {
+ for (i = 0; i < TABLE_LOAD_RETRIES; i++) {
+ if (! ioctl(fd, DM_TABLE_LOAD, io)) {
+ break;
+ }
+ usleep(500000);
+ }
+
+ if (i == TABLE_LOAD_RETRIES) {
SLOGE("Cannot load dm-crypt mapping table.\n");
goto errout;
+ } else if (i) {
+ SLOGI("Took %d tries to load dmcrypt table.\n", i + 1);
}
/* Resume this device to activate it */
@@ -676,6 +688,13 @@ int cryptfs_restart(void)
property_set("vold.decrypt", "trigger_reset_main");
SLOGD("Just asked init to shut down class main\n");
+ /* Ugh, shutting down the framework is not synchronous, so until it
+ * can be fixed, this horrible hack will wait a moment for it all to
+ * shut down before proceeding. Without it, some devices cannot
+ * restart the graphics services.
+ */
+ sleep(2);
+
/* Now that the framework is shutdown, we should be able to umount()
* the tmpfs filesystem, and mount the real one.
*/
@@ -1179,11 +1198,14 @@ int cryptfs_enable(char *howarg, char *passwd)
snprintf(lockid, sizeof(lockid), "enablecrypto%d", (int) getpid());
acquire_wake_lock(PARTIAL_WAKE_LOCK, lockid);
- /* Get the sdcard mount point */
- sd_mnt_point = getenv("EXTERNAL_STORAGE");
- if (! sd_mnt_point) {
- sd_mnt_point = "/mnt/sdcard";
- }
+ /* Get the sdcard mount point */
+ sd_mnt_point = getenv("EMULATED_STORAGE_SOURCE");
+ if (!sd_mnt_point) {
+ sd_mnt_point = getenv("EXTERNAL_STORAGE");
+ }
+ if (!sd_mnt_point) {
+ sd_mnt_point = "/mnt/sdcard";
+ }
num_vols=vold_getNumDirectVolumes();
vol_list = malloc(sizeof(struct volume_info) * num_vols);
@@ -1257,6 +1279,13 @@ int cryptfs_enable(char *howarg, char *passwd)
goto error_shutting_down;
}
+ /* Ugh, shutting down the framework is not synchronous, so until it
+ * can be fixed, this horrible hack will wait a moment for it all to
+ * shut down before proceeding. Without it, some devices cannot
+ * restart the graphics services.
+ */
+ sleep(2);
+
/* startup service classes main and late_start */
property_set("vold.decrypt", "trigger_restart_min_framework");
SLOGD("Just triggered restart_min_framework\n");
@@ -1365,12 +1394,12 @@ int cryptfs_enable(char *howarg, char *passwd)
} else {
char value[PROPERTY_VALUE_MAX];
- property_get("ro.vold.wipe_on_cyrypt_fail", value, "0");
+ property_get("ro.vold.wipe_on_crypt_fail", value, "0");
if (!strcmp(value, "1")) {
/* wipe data if encryption failed */
SLOGE("encryption failed - rebooting into recovery to wipe data\n");
mkdir("/cache/recovery", 0700);
- int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC);
+ int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd >= 0) {
write(fd, "--wipe_data", strlen("--wipe_data") + 1);
close(fd);