OSDN Git Service

vold: set state back to idle on formatting error
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 16 Nov 2010 05:18:19 +0000 (13:18 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 16 Nov 2010 05:27:36 +0000 (13:27 +0800)
On formatting error due to some reasons, the state is left at
Formatting, therefore the user is unable to mount the sdcard
again. The patch sets the state to Idle no matter formatting
error or not.

Change-Id: I62c78eb8299cc397ee5cc442890f8b3dbf09425c

Volume.cpp

index 2f3cad5..4ac086b 100644 (file)
@@ -213,6 +213,7 @@ int Volume::formatVol() {
     }
     setState(Volume::State_Formatting);
 
+    int ret = -1;
     if (initializeMbr(devicePath)) {
         SLOGE("Failed to initialize MBR (%s)", strerror(errno));
         goto err;
@@ -226,10 +227,11 @@ int Volume::formatVol() {
         goto err;
     }
 
-    setState(Volume::State_Idle);
-    return 0;
+    ret = 0;
+
 err:
-    return -1;
+    setState(Volume::State_Idle);
+    return ret;
 }
 
 bool Volume::isMountpointMounted(const char *path) {