OSDN Git Service

DO NOT MERGE Retry unmounts in ext4 encryption
authorPaul Lawrence <paullawrence@google.com>
Tue, 5 May 2015 21:28:25 +0000 (14:28 -0700)
committerPaul Lawrence <paullawrence@google.com>
Fri, 29 May 2015 21:20:51 +0000 (14:20 -0700)
(cherry-picked from commit 29b54aab8ee2d08e2129832364f9b719dd17fa4e)

Bug: 18151196
Change-Id: I52ca23b2ce3adcff44bd003d4a12243a0bd6ac34

Ext4Crypt.cpp
cryptfs.c
cryptfs.h

index 9c79098..150014c 100644 (file)
@@ -381,16 +381,14 @@ int e4crypt_restart(const char* path)
 
     std::string tmp_path = std::string() + path + "/tmp_mnt";
 
-    // ext4enc:TODO add retry logic
-    rc = umount(tmp_path.c_str());
+    rc = wait_and_unmount(tmp_path.c_str(), true);
     if (rc) {
         SLOGE("umount %s failed with rc %d, msg %s",
               tmp_path.c_str(), rc, strerror(errno));
         return rc;
     }
 
-    // ext4enc:TODO add retry logic
-    rc = umount(path);
+    rc = wait_and_unmount(path, true);
     if (rc) {
         SLOGE("umount %s failed with rc %d, msg %s",
               path, rc, strerror(errno));
index 47b19a6..2306e4a 100644 (file)
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -1426,7 +1426,7 @@ static int create_encrypted_random_key(char *passwd, unsigned char *master_key,
     return encrypt_master_key(passwd, salt, key_buf, master_key, crypt_ftr);
 }
 
-static int wait_and_unmount(char *mountpoint, bool kill)
+int wait_and_unmount(const char *mountpoint, bool kill)
 {
     int i, err, rc;
 #define WAIT_UNMOUNT_COUNT 20
index fa3d351..94684e2 100644 (file)
--- a/cryptfs.h
+++ b/cryptfs.h
@@ -26,6 +26,7 @@
  * partition.
  */
 
+#include <stdbool.h>
 #include <cutils/properties.h>
 
 /* The current cryptfs version */
@@ -208,6 +209,8 @@ struct crypt_persist_data {
 extern "C" {
 #endif
 
+  int wait_and_unmount(const char *mountpoint, bool kill);
+
   typedef int (*kdf_func)(const char *passwd, const unsigned char *salt,
                           unsigned char *ikey, void *params);