summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Malmborn <magnus.malmborn@sonyericsson.com>2011-01-19 12:26:52 +0100
committerBjorn Andersson <bjorn.andersson@sonymobile.com>2012-05-07 17:23:15 -0700
commit3dafc26e4f3adb9607e82ab0bd52ead5f76859a1 (patch)
tree1f0718d3ca2b5cf87ab2b6e4a6b87d19ca6a8cb4
parent3ad9072a5d6f6bda32123b367545649364e3c11d (diff)
downloadsystem_vold-3dafc26e4f3adb9607e82ab0bd52ead5f76859a1.zip
system_vold-3dafc26e4f3adb9607e82ab0bd52ead5f76859a1.tar.gz
system_vold-3dafc26e4f3adb9607e82ab0bd52ead5f76859a1.tar.bz2
Delay disk inserted broadcast until disk is ready
Delay sending of "VolumeDiskInserted" broadcast until the disk is ready (ie until all the partitions have been received from kernel). This solves a race with MountService, otherwise there is a risk that MountService tries to mount the SD-card before the partition(s) have been received and the card will fail to mount. Change-Id: Ie2a28227ae9a7d6fe9106fb6875f469a0e899014
-rw-r--r--DirectVolume.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/DirectVolume.cpp b/DirectVolume.cpp
index 4acee76..9a064e7 100644
--- a/DirectVolume.cpp
+++ b/DirectVolume.cpp
@@ -113,6 +113,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);
@@ -148,8 +158,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++) {
@@ -169,11 +177,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) {