summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOran Avraham <oranav@gmail.com>2012-11-02 18:18:48 +0200
committerOran Avraham <oranav@gmail.com>2012-11-02 18:18:48 +0200
commit3e61f1d12494ac0f456623681f12edf9b356245f (patch)
tree7048d110687d801d0f538bf46b96c19ac3dc0c11
parent42c34c801f918507397754f185f85d79d8558d39 (diff)
downloadandroid_system_vold-jellybean-stable.tar.gz
android_system_vold-jellybean-stable.tar.bz2
android_system_vold-jellybean-stable.zip
UMS support with any volume, not only primary (1/3)jellybean-stable
This patch enables UMS support when any volume supports it, even when the primary storage doesn't. 1. Vold: assign lun_numbers sequentially to the volumes being added to the VolumeManager. 2. Fix portions of code which assume that the device has UMS support iff the primary storage supports UMS. Instead, determine whether the device supports UMS by checking each volume. 3. Display the UMS option in Settings.apk when any volume supports it. Change-Id: I3976ee4a26f1ae7bd3faee814d3740312588f4c8 Signed-off-by: Oran Avraham <oranav@gmail.com>
-rw-r--r--Volume.cpp5
-rw-r--r--Volume.h4
-rw-r--r--VolumeManager.cpp20
-rw-r--r--VolumeManager.h1
4 files changed, 17 insertions, 13 deletions
diff --git a/Volume.cpp b/Volume.cpp
index b38f3b5..0e4f277 100644
--- a/Volume.cpp
+++ b/Volume.cpp
@@ -123,6 +123,7 @@ Volume::Volume(VolumeManager *vm, const char *label, const char *mount_point) {
mCurrentlyMountedKdev = -1;
mPartIdx = -1;
mRetryMount = false;
+ mLunNumber = -1;
property_get("persist.sys.vold.switchexternal", switchable, "0");
if (!strcmp(switchable,"1")) {
@@ -200,6 +201,10 @@ bool Volume::isPrimaryStorage() {
return !strcmp(getMountpoint(), externalStorage);
}
+void Volume::setLunNumber(int lunNumber) {
+ mLunNumber = lunNumber;
+}
+
void Volume::setState(int state) {
char msg[255];
int oldState = mState;
diff --git a/Volume.h b/Volume.h
index 31fa653..9dd263e 100644
--- a/Volume.h
+++ b/Volume.h
@@ -55,6 +55,7 @@ protected:
int mPartIdx;
int mOrigPartIdx;
bool mRetryMount;
+ int mLunNumber;
/*
* The major/minor tuple of the currently mounted filesystem.
@@ -74,6 +75,9 @@ public:
int getState() { return mState; }
bool isPrimaryStorage();
+ int getLunNumber() { return mLunNumber; }
+ void setLunNumber(int lunNumber);
+
virtual int handleBlockEvent(NetlinkEvent *evt);
virtual dev_t getDiskDevice();
virtual dev_t getShareDevice();
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index ca30357..040e95c 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -66,6 +66,7 @@ VolumeManager::VolumeManager() {
mUmsSharingCount = 0;
mSavedDirtyRatio = -1;
mVolManagerDisabled = 0;
+ mNextLunNumber = 0;
// set dirty ratio to ro.vold.umsdirtyratio (default 0) when UMS is active
char dirtyratio[PROPERTY_VALUE_MAX];
@@ -127,6 +128,7 @@ int VolumeManager::stop() {
}
int VolumeManager::addVolume(Volume *v) {
+ v->setLunNumber(mNextLunNumber++);
mVolumes->push_back(v);
return 0;
}
@@ -1269,12 +1271,8 @@ int VolumeManager::shareVolume(const char *label, const char *method) {
sizeof(nodepath), "/dev/block/vold/%d:%d",
MAJOR(d), MINOR(d));
- // TODO: Currently only two mounts are supported, defaulting
- // /mnt/sdcard to lun0 and anything else to lun1. Fix this.
- if (v->isPrimaryStorage()) {
- lun_number = 0;
- } else {
- lun_number = SECOND_LUN_NUM;
+ if ((lun_number = v->getLunNumber()) == -1) {
+ return -1;
}
if ((fd = openLun(lun_number)) < 0) {
@@ -1325,14 +1323,10 @@ int VolumeManager::unshareVolume(const char *label, const char *method) {
return -1;
}
- int fd;
- int lun_number;
+ int fd, lun_number;
- // /mnt/sdcard to lun0 and anything else to lun1. Fix this.
- if (v->isPrimaryStorage()) {
- lun_number = 0;
- } else {
- lun_number = SECOND_LUN_NUM;
+ if ((lun_number = v->getLunNumber()) == -1) {
+ return -1;
}
if ((fd = openLun(lun_number)) < 0) {
diff --git a/VolumeManager.h b/VolumeManager.h
index e51fb70..334b81b 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -74,6 +74,7 @@ private:
int mSavedDirtyRatio;
int mUmsDirtyRatio;
int mVolManagerDisabled;
+ int mNextLunNumber;
public:
virtual ~VolumeManager();