From 627366196859339d72ab9f68a817dd395a13468f Mon Sep 17 00:00:00 2001 From: Lars Svensson Date: Thu, 7 Apr 2011 15:17:43 +0200 Subject: Unshare ums when SD card is removed If SD card is removed without unmounting when in USB mass storage mode the ums share is not properly closed and the device files 179:0 and 179:1 are left in use. This causes erratic behaviour on subsequent operations on the card, i.e. mounting and formatting will fail. Change-Id: I757703c6282f4b76e2d8b027f4644920737309b6 --- DirectVolume.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DirectVolume.cpp b/DirectVolume.cpp index 4acee76..c745c93 100644 --- a/DirectVolume.cpp +++ b/DirectVolume.cpp @@ -275,6 +275,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)", -- cgit v1.1