summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2011-08-19 18:42:27 +0100
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-07-10 20:10:35 +0100
commitdc8d157d73fb88ee33b38e724a8aabe7d5e53eee (patch)
tree19bc20927f25190f5e176d2c5ef129dd45dac13e
parentce7457dfe9706b24bbfe98af82adceab50c2198e (diff)
downloadsystem_vold-dc8d157d73fb88ee33b38e724a8aabe7d5e53eee.zip
system_vold-dc8d157d73fb88ee33b38e724a8aabe7d5e53eee.tar.gz
system_vold-dc8d157d73fb88ee33b38e724a8aabe7d5e53eee.tar.bz2
vold: Allow pre-configured device pairs to switch mountpoints
The use-case for this are devices with internal extended storage (pseudo-SDCard emmc) and an actual microSD card reader. In CM, we choose to use the microSD as primary storage, and leave the internal partition mostly unused; some users usually come up with imaginative and data-destroying ways of working around that. This allows us to specify a pair of mountpoints which can be switched from a user preference. For this vold.fstab: ----- dev_mount sdcard /mnt/sdcard ...<path-to-microSD-sysfs> dev_mount emmc /mnt/emmc ...<path-to-emmc-partition> ----- We can add to build.prop: "ro.vold.switchablepair=/mnt/sdcard,/mnt/emmc" A persistent toggle (persist.sys.vold.switchexternal), controllable through CMParts, can be presented to the user to allow choosing something other than our default as primary storage. Change-Id: I9559fa442c833e3168287d820b7b8347736abb15
-rw-r--r--Volume.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/Volume.cpp b/Volume.cpp
index 624c3f0..b38f3b5 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -114,6 +114,7 @@ static const char *stateToStr(int state) {
}
Volume::Volume(VolumeManager *vm, const char *label, const char *mount_point) {
+ char switchable[PROPERTY_VALUE_MAX];
mVm = vm;
mDebug = false;
mLabel = strdup(label);
@@ -122,6 +123,29 @@ Volume::Volume(VolumeManager *vm, const char *label, const char *mount_point) {
mCurrentlyMountedKdev = -1;
mPartIdx = -1;
mRetryMount = false;
+
+ property_get("persist.sys.vold.switchexternal", switchable, "0");
+ if (!strcmp(switchable,"1")) {
+ char *first, *second = NULL;
+ const char *delim = ",";
+
+ property_get("ro.vold.switchablepair", switchable, "");
+
+ if (!(first = strtok(switchable, delim))) {
+ SLOGE("Mount switch requested, but no switchable mountpoints found");
+ return;
+ } else if (!(second = strtok(NULL, delim))) {
+ SLOGE("Mount switch requested, but bad switchable mountpoints found");
+ return;
+ }
+ if (!strcmp(mount_point,first)) {
+ free(mMountpoint);
+ mMountpoint = strdup(second);
+ } else if (!strcmp(mount_point,second)) {
+ free(mMountpoint);
+ mMountpoint = strdup(first);
+ }
+ }
}
Volume::~Volume() {