diff --git a/Android.mk b/Android.mk
index ca0a21b..69be87d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -33,6 +33,7 @@
 	ScryptParameters.cpp \
 	secontext.cpp \
 	EncryptInplace.cpp \
+	MetadataCrypt.cpp \
 
 common_c_includes := \
 	system/extras/f2fs_utils \
diff --git a/CryptCommandListener.cpp b/CryptCommandListener.cpp
index 0c2509c..5c2ac84 100644
--- a/CryptCommandListener.cpp
+++ b/CryptCommandListener.cpp
@@ -50,6 +50,7 @@
 #include "ResponseCode.h"
 #include "cryptfs.h"
 #include "Ext4Crypt.h"
+#include "MetadataCrypt.h"
 #include "Utils.h"
 
 #define DUMP_ARGS 0
@@ -201,6 +202,15 @@
         dumpArgs(argc, argv, -1);
         rc = cryptfs_crypto_complete();
     } else if (subcommand == "enablecrypto") {
+        if (e4crypt_is_native()) {
+            if (argc != 5 || strcmp(argv[2], "inplace") || strcmp(argv[3], "default")
+                    || strcmp(argv[4], "noui")) {
+                cli->sendMsg(ResponseCode::CommandSyntaxError,
+                        "Usage with ext4crypt: cryptfs enablecrypto inplace default noui", false);
+                return 0;
+            }
+            return sendGenericOkFailOnBool(cli, e4crypt_enable_crypto());
+        }
         const char* syntax = "Usage: cryptfs enablecrypto <wipe|inplace> "
                              "default|password|pin|pattern [passwd] [noui]";
 
@@ -318,6 +328,9 @@
         SLOGD("cryptfs mountdefaultencrypted");
         dumpArgs(argc, argv, -1);
 
+        if (e4crypt_is_native()) {
+            return sendGenericOkFailOnBool(cli, e4crypt_mount_metadata_encrypted());
+        }
         // Spawn as thread so init can issue commands back to vold without
         // causing deadlock, usually as a result of prep_data_fs.
         std::thread(&cryptfs_mount_default_encrypted).detach();
diff --git a/KeyUtil.cpp b/KeyUtil.cpp
index 37398e6..4d507a1 100644
--- a/KeyUtil.cpp
+++ b/KeyUtil.cpp
@@ -74,7 +74,7 @@
     return true;
 }
 
-static std::string keyname(const std::string& raw_ref) {
+std::string keyname(const std::string& raw_ref) {
     std::ostringstream o;
     o << "ext4:";
     for (auto i : raw_ref) {
@@ -163,5 +163,23 @@
     return true;
 }
 
+bool retrieveKey(bool create_if_absent, const std::string& key_path,
+                 const std::string& tmp_path, std::string* key) {
+    if (pathExists(key_path)) {
+        LOG(DEBUG) << "Key exists, using: " << key_path;
+        if (!retrieveKey(key_path, kEmptyAuthentication, key)) return false;
+    } else {
+        if (!create_if_absent) {
+           LOG(ERROR) << "No key found in " << key_path;
+           return false;
+        }
+        LOG(INFO) << "Creating new key in " << key_path;
+        if (!randomKey(key)) return false;
+        if (!storeKeyAtomically(key_path, tmp_path,
+                kEmptyAuthentication, *key)) return false;
+    }
+    return true;
+}
+
 }  // namespace vold
 }  // namespace android
diff --git a/KeyUtil.h b/KeyUtil.h
index 56cb189..f8fb634 100644
--- a/KeyUtil.h
+++ b/KeyUtil.h
@@ -36,11 +36,14 @@
     uint32_t size;
 };
 
+std::string keyname(const std::string& raw_ref);
 bool randomKey(std::string* key);
 bool installKey(const std::string& key, std::string* raw_ref);
 bool evictKey(const std::string& raw_ref);
 bool retrieveAndInstallKey(bool create_if_absent, const std::string& key_path,
                            const std::string& tmp_path, std::string* key_ref);
+bool retrieveKey(bool create_if_absent, const std::string& key_path,
+                 const std::string& tmp_path, std::string* key);
 
 }  // namespace vold
 }  // namespace android
diff --git a/MetadataCrypt.cpp b/MetadataCrypt.cpp
new file mode 100644
index 0000000..b707549
--- /dev/null
+++ b/MetadataCrypt.cpp
@@ -0,0 +1,312 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MetadataCrypt.h"
+
+#include <string>
+#include <thread>
+#include <vector>
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <linux/dm-ioctl.h>
+
+#include <android-base/logging.h>
+#include <cutils/properties.h>
+#include <fs_mgr.h>
+
+#include "AutoCloseFD.h"
+#include "EncryptInplace.h"
+#include "KeyStorage.h"
+#include "KeyUtil.h"
+#include "secontext.h"
+#include "Utils.h"
+#include "VoldUtil.h"
+
+extern struct fstab *fstab;
+#define DM_CRYPT_BUF_SIZE 4096
+#define TABLE_LOAD_RETRIES 10
+#define DEFAULT_KEY_TARGET_TYPE "default-key"
+
+static const std::string kDmNameUserdata = "userdata";
+
+static bool mount_via_fs_mgr(const char* mount_point, const char* blk_device) {
+    // fs_mgr_do_mount runs fsck. Use setexeccon to run trusted
+    // partitions in the fsck domain.
+    if (setexeccon(secontextFsck())) {
+        PLOG(ERROR) << "Failed to setexeccon";
+        return false;
+    }
+    auto mount_rc = fs_mgr_do_mount(fstab, const_cast<char*>(mount_point),
+                                    const_cast<char*>(blk_device), nullptr);
+    if (setexeccon(nullptr)) {
+        PLOG(ERROR) << "Failed to clear setexeccon";
+        return false;
+    }
+    if (mount_rc != 0) {
+        LOG(ERROR) << "fs_mgr_do_mount failed with rc " << mount_rc;
+        return false;
+    }
+    LOG(DEBUG) << "Mounted " << mount_point;
+    return true;
+}
+
+static bool read_key(bool create_if_absent, std::string* key) {
+    auto data_rec = fs_mgr_get_crypt_entry(fstab);
+    if (!data_rec) {
+        LOG(ERROR) << "Failed to get data_rec";
+        return false;
+    }
+    if (!data_rec->key_dir) {
+        LOG(ERROR) << "Failed to get key_dir";
+        return false;
+    }
+    LOG(DEBUG) << "key_dir: " << data_rec->key_dir;
+    if (!android::vold::pathExists(data_rec->key_dir)) {
+        if (mkdir(data_rec->key_dir, 0777) != 0) {
+            PLOG(ERROR) << "Unable to create: " << data_rec->key_dir;
+            return false;
+        }
+        LOG(DEBUG) << "Created: " << data_rec->key_dir;
+    }
+    std::string key_dir = data_rec->key_dir;
+    auto dir = key_dir + "/key";
+    auto temp = key_dir + "/tmp";
+    if (!android::vold::retrieveKey(create_if_absent, dir, temp, key)) return false;
+    return true;
+}
+
+static std::string default_key_params(const std::string& real_blkdev, const std::string& key) {
+    std::string hex_key;
+    if (android::vold::StrToHex(key, hex_key) != android::OK) {
+        LOG(ERROR) << "Failed to turn key to hex";
+        return "";
+    }
+    auto res = std::string() + "AES-256-XTS " + hex_key + " " + real_blkdev + " 0";
+    LOG(DEBUG) << "crypt_params: " << res;
+    return res;
+}
+
+static bool get_number_of_sectors(const std::string& real_blkdev, uint64_t *nr_sec) {
+    AutoCloseFD dev_fd(real_blkdev, O_RDONLY);
+    if (!dev_fd) {
+        PLOG(ERROR) << "Unable to open " << real_blkdev << " to measure size";
+        return false;
+    }
+    unsigned long res;
+    // TODO: should use BLKGETSIZE64
+    get_blkdev_size(dev_fd.get(), &res);
+    if (res == 0) {
+        PLOG(ERROR) << "Unable to measure size of " << real_blkdev;
+        return false;
+    }
+    *nr_sec = res;
+    return true;
+}
+
+static struct dm_ioctl* dm_ioctl_init(char *buffer, size_t buffer_size,
+                                      const std::string& dm_name) {
+    if (buffer_size < sizeof(dm_ioctl)) {
+        LOG(ERROR) << "dm_ioctl buffer too small";
+        return nullptr;
+    }
+
+    memset(buffer, 0, buffer_size);
+    struct dm_ioctl* io = (struct dm_ioctl*) buffer;
+    io->data_size = buffer_size;
+    io->data_start = sizeof(struct dm_ioctl);
+    io->version[0] = 4;
+    io->version[1] = 0;
+    io->version[2] = 0;
+    io->flags = 0;
+    dm_name.copy(io->name, sizeof(io->name));
+    return io;
+}
+
+static bool create_crypto_blk_dev(const std::string& dm_name, uint64_t nr_sec,
+                                  const std::string& target_type, const std::string& crypt_params,
+                                  std::string* crypto_blkdev) {
+    AutoCloseFD dm_fd("/dev/device-mapper", O_RDWR);
+    if (!dm_fd) {
+        PLOG(ERROR) << "Cannot open device-mapper";
+        return false;
+    }
+    alignas(struct dm_ioctl) char buffer[DM_CRYPT_BUF_SIZE];
+    auto io = dm_ioctl_init(buffer, sizeof(buffer), dm_name);
+    if (!io || ioctl(dm_fd.get(), DM_DEV_CREATE, io) != 0) {
+        PLOG(ERROR) << "Cannot create dm-crypt device " << dm_name;
+        return false;
+    }
+
+    // Get the device status, in particular, the name of its device file
+    io = dm_ioctl_init(buffer, sizeof(buffer), dm_name);
+    if (ioctl(dm_fd.get(), DM_DEV_STATUS, io) != 0) {
+        PLOG(ERROR) << "Cannot retrieve dm-crypt device status " << dm_name;
+        return false;
+    }
+    *crypto_blkdev = std::string() + "/dev/block/dm-" + std::to_string(
+        (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00));
+
+    io = dm_ioctl_init(buffer, sizeof(buffer), dm_name);
+    unsigned long paramix = io->data_start + sizeof(struct dm_target_spec);
+    unsigned long nullix = paramix + crypt_params.size();
+    unsigned long endix = (nullix + 1 + 7) & 8; // Add room for \0 and align to 8 byte boundary
+
+    if (endix > sizeof(buffer)) {
+        LOG(ERROR) << "crypt_params too big for DM_CRYPT_BUF_SIZE";
+        return false;
+    }
+
+    io->target_count = 1;
+    auto tgt = (struct dm_target_spec *) (buffer + io->data_start);
+    tgt->status = 0;
+    tgt->sector_start = 0;
+    tgt->length = nr_sec;
+    target_type.copy(tgt->target_type, sizeof(tgt->target_type));
+    crypt_params.copy(buffer + paramix, sizeof(buffer) - paramix);
+    buffer[nullix] = '\0';
+    tgt->next = endix;
+
+    for (int i = 0; ; i++) {
+        if (ioctl(dm_fd.get(), DM_TABLE_LOAD, io) == 0) {
+            break;
+        }
+        if (i+1 >= TABLE_LOAD_RETRIES) {
+            PLOG(ERROR) << "DM_TABLE_LOAD ioctl failed";
+            return false;
+        }
+        PLOG(INFO) << "DM_TABLE_LOAD ioctl failed, retrying";
+        usleep(500000);
+    }
+
+    // Resume this device to activate it
+    io = dm_ioctl_init(buffer, sizeof(buffer), dm_name);
+    if (ioctl(dm_fd.get(), DM_DEV_SUSPEND, io)) {
+        PLOG(ERROR) << "Cannot resume dm-crypt device " << dm_name;
+        return false;
+    }
+    return true;
+}
+
+#define DATA_PREP_TIMEOUT 1000
+static bool prep_data_fs(void)
+{
+    // NOTE: post_fs_data results in init calling back around to vold, so all
+    // callers to this method must be async
+
+    /* Do the prep of the /data filesystem */
+    property_set("vold.post_fs_data_done", "0");
+    property_set("vold.decrypt", "trigger_post_fs_data");
+    LOG(DEBUG) << "Waiting for post_fs_data_done";
+
+    /* Wait a max of 50 seconds, hopefully it takes much less */
+    for (int i = 0; ; i++) {
+        char p[PROPERTY_VALUE_MAX];
+
+        property_get("vold.post_fs_data_done", p, "0");
+        if (*p == '1') {
+            LOG(INFO) << "Successful data prep";
+            return true;
+        }
+        if (i + 1 == DATA_PREP_TIMEOUT) {
+            LOG(ERROR) << "post_fs_data timed out";
+            return false;
+        }
+        usleep(50000);
+    }
+}
+
+static void async_kick_off() {
+    LOG(DEBUG) << "Asynchronously restarting framework";
+    sleep(2); // TODO: this mirrors cryptfs, but can it be made shorter?
+    property_set("vold.decrypt", "trigger_load_persist_props");
+    if (!prep_data_fs()) return;
+    /* startup service classes main and late_start */
+    property_set("vold.decrypt", "trigger_restart_framework");
+}
+
+bool e4crypt_mount_metadata_encrypted() {
+    LOG(DEBUG) << "e4crypt_mount_default_encrypted";
+    std::string key;
+    if (!read_key(false, &key)) return false;
+    auto data_rec = fs_mgr_get_crypt_entry(fstab);
+    if (!data_rec) {
+        LOG(ERROR) << "Failed to get data_rec";
+        return false;
+    }
+    uint64_t nr_sec;
+    if (!get_number_of_sectors(data_rec->blk_device, &nr_sec)) return false;
+    std::string crypto_blkdev;
+    if (!create_crypto_blk_dev(kDmNameUserdata, nr_sec, DEFAULT_KEY_TARGET_TYPE,
+        default_key_params(data_rec->blk_device, key), &crypto_blkdev)) return false;
+    // FIXME handle the corrupt case
+
+    LOG(DEBUG) << "Restarting filesystem for metadata encryption";
+    mount_via_fs_mgr(data_rec->mount_point, crypto_blkdev.c_str());
+    std::thread(&async_kick_off).detach();
+    return true;
+}
+
+bool e4crypt_enable_crypto() {
+    LOG(DEBUG) << "e4crypt_enable_crypto";
+    char encrypted_state[PROPERTY_VALUE_MAX];
+    property_get("ro.crypto.state", encrypted_state, "");
+    if (strcmp(encrypted_state, "")) {
+        LOG(DEBUG) << "e4crypt_enable_crypto got unexpected starting state: " << encrypted_state;
+        return false;
+    }
+
+    std::string key_ref;
+    if (!read_key(true, &key_ref)) return false;
+
+    auto data_rec = fs_mgr_get_crypt_entry(fstab);
+    if (!data_rec) {
+        LOG(ERROR) << "Failed to get data_rec";
+        return false;
+    }
+    uint64_t nr_sec;
+    if (!get_number_of_sectors(data_rec->blk_device, &nr_sec)) return false;
+
+    std::string crypto_blkdev;
+    if (!create_crypto_blk_dev(kDmNameUserdata, nr_sec, DEFAULT_KEY_TARGET_TYPE,
+        default_key_params(data_rec->blk_device, key_ref), &crypto_blkdev)) return false;
+
+    LOG(INFO) << "Beginning inplace encryption, nr_sec: " << nr_sec;
+    off64_t size_already_done = 0;
+    auto rc = cryptfs_enable_inplace(const_cast<char *>(crypto_blkdev.c_str()),
+                                     data_rec->blk_device, nr_sec, &size_already_done, nr_sec, 0);
+    if (rc != 0) {
+        LOG(ERROR) << "Inplace crypto failed with code: " << rc;
+        return false;
+    }
+    if (static_cast<uint64_t>(size_already_done) != nr_sec) {
+        LOG(ERROR) << "Inplace crypto only got up to sector: " << size_already_done;
+        return false;
+    }
+    LOG(INFO) << "Inplace encryption complete";
+
+    property_set("ro.crypto.state", "encrypted");
+    property_set("ro.crypto.type", "file");
+
+    mount_via_fs_mgr(data_rec->mount_point, crypto_blkdev.c_str());
+    property_set("vold.decrypt", "trigger_reset_main");
+    std::thread(&async_kick_off).detach();
+    return true;
+}
diff --git a/MetadataCrypt.h b/MetadataCrypt.h
new file mode 100644
index 0000000..f6634ea
--- /dev/null
+++ b/MetadataCrypt.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _METADATA_CRYPT_H
+#define _METADATA_CRYPT_H
+
+bool e4crypt_mount_metadata_encrypted();
+bool e4crypt_enable_crypto();
+
+#endif
