diff --git a/Android.mk b/Android.mk
index 27ffec7..cacb628 100644
--- a/Android.mk
+++ b/Android.mk
@@ -12,8 +12,7 @@
     install.c \
     roots.c \
     ui.c \
-    verifier.c \
-    encryptedfs_provisioning.c
+    verifier.c
 
 LOCAL_MODULE := recovery
 
diff --git a/encryptedfs_provisioning.c b/encryptedfs_provisioning.c
deleted file mode 100644
index 601c817..0000000
--- a/encryptedfs_provisioning.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2009 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "encryptedfs_provisioning.h"
-#include "cutils/misc.h"
-#include "cutils/properties.h"
-#include "common.h"
-#include "mtdutils/mtdutils.h"
-#include "mtdutils/mounts.h"
-#include "roots.h"
-
-const char* encrypted_fs_enabled_property      = "persist.security.secfs.enabled";
-const char* encrypted_fs_property_dir          = "/data/property/";
-const char* encrypted_fs_system_dir            = "/data/system/";
-const char* encrypted_fs_key_file_name         = "/data/fs_key.dat";
-const char* encrypted_fs_salt_file_name        = "/data/hash_salt.dat";
-const char* encrypted_fs_hash_file_src_name    = "/data/system/password.key";
-const char* encrypted_fs_hash_file_dst_name    = "/data/hash.dat";
-const char* encrypted_fs_entropy_file_src_name = "/data/system/entropy.dat";
-const char* encrypted_fs_entropy_file_dst_name = "/data/ported_entropy.dat";
-
-void get_property_file_name(char *buffer, const char *property_name) {
-    sprintf(buffer, "%s%s", encrypted_fs_property_dir, property_name);
-}
-
-int get_binary_file_contents(char *buffer, int buf_size, const char *file_name, int *out_size) {
-    FILE *in_file;
-    int read_bytes;
-
-    in_file = fopen(file_name, "r");
-    if (in_file == NULL) {
-        LOGE("Secure FS: error accessing key file.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    read_bytes = fread(buffer, 1, buf_size, in_file);
-    if (out_size == NULL) {
-        if (read_bytes != buf_size) {
-            // Error or unexpected data
-            fclose(in_file);
-            LOGE("Secure FS: error reading conmplete key.");
-            return ENCRYPTED_FS_ERROR;
-        }
-    } else {
-        *out_size = read_bytes;
-    }
-    fclose(in_file);
-    return ENCRYPTED_FS_OK;
-}
-
-int set_binary_file_contents(char *buffer, int buf_size, const char *file_name) {
-    FILE *out_file;
-    int write_bytes;
-
-    out_file = fopen(file_name, "w");
-    if (out_file == NULL) {
-        LOGE("Secure FS: error setting up key file.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    write_bytes = fwrite(buffer, 1, buf_size, out_file);
-    if (write_bytes != buf_size) {
-        // Error or unexpected data
-        fclose(out_file);
-        LOGE("Secure FS: error reading conmplete key.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    fclose(out_file);
-    return ENCRYPTED_FS_OK;
-}
-
-int get_text_file_contents(char *buffer, int buf_size, char *file_name) {
-    FILE *in_file;
-    char *read_data;
-
-    in_file = fopen(file_name, "r");
-    if (in_file == NULL) {
-        LOGE("Secure FS: error accessing properties.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    read_data = fgets(buffer, buf_size, in_file);
-    if (read_data == NULL) {
-        // Error or unexpected data
-        fclose(in_file);
-        LOGE("Secure FS: error accessing properties.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    fclose(in_file);
-    return ENCRYPTED_FS_OK;
-}
-
-int set_text_file_contents(char *buffer, char *file_name) {
-    FILE *out_file;
-    int result;
-
-    out_file = fopen(file_name, "w");
-    if (out_file == NULL) {
-        LOGE("Secure FS: error setting up properties.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = fputs(buffer, out_file);
-    if (result != 0) {
-        // Error or unexpected data
-        fclose(out_file);
-        LOGE("Secure FS: error setting up properties.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    fflush(out_file);
-    fclose(out_file);
-    return ENCRYPTED_FS_OK;
-}
-
-int read_encrypted_fs_boolean_property(const char *prop_name, int *value) {
-    char prop_file_name[PROPERTY_KEY_MAX + 32];
-    char prop_value[PROPERTY_VALUE_MAX];
-    int result;
-
-    get_property_file_name(prop_file_name, prop_name);
-    result = get_text_file_contents(prop_value, PROPERTY_VALUE_MAX, prop_file_name);
-
-    if (result < 0) {
-        return result;
-    }
-
-    if (strncmp(prop_value, "1", 1) == 0) {
-        *value = 1;
-    } else if (strncmp(prop_value, "0", 1) == 0) {
-        *value = 0;
-    } else {
-        LOGE("Secure FS: error accessing properties.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    return ENCRYPTED_FS_OK;
-}
-
-int write_encrypted_fs_boolean_property(const char *prop_name, int value) {
-    char prop_file_name[PROPERTY_KEY_MAX + 32];
-    char prop_value[PROPERTY_VALUE_MAX];
-    int result;
-
-    get_property_file_name(prop_file_name, prop_name);
-
-    // Create the directory if needed
-    mkdir(encrypted_fs_property_dir, 0755);
-    if (value == 1) {
-        result = set_text_file_contents("1", prop_file_name);
-    } else if (value == 0) {
-        result = set_text_file_contents("0", prop_file_name);
-    } else {
-        return ENCRYPTED_FS_ERROR;
-    }
-    if (result < 0) {
-        return result;
-    }
-
-    return ENCRYPTED_FS_OK;
-}
-
-int read_encrypted_fs_info(encrypted_fs_info *encrypted_fs_data) {
-    int result;
-    int value;
-    result = ensure_path_mounted("/data");
-    if (result != 0) {
-        LOGE("Secure FS: error mounting userdata partition.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    // Read the pre-generated encrypted FS key, password hash and salt.
-    result = get_binary_file_contents(encrypted_fs_data->key, ENCRYPTED_FS_KEY_SIZE,
-            encrypted_fs_key_file_name, NULL);
-    if (result != 0) {
-        LOGE("Secure FS: error reading generated file system key.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = get_binary_file_contents(encrypted_fs_data->salt, ENCRYPTED_FS_SALT_SIZE,
-            encrypted_fs_salt_file_name, &(encrypted_fs_data->salt_length));
-    if (result != 0) {
-        LOGE("Secure FS: error reading file system salt.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = get_binary_file_contents(encrypted_fs_data->hash, ENCRYPTED_FS_MAX_HASH_SIZE,
-            encrypted_fs_hash_file_src_name, &(encrypted_fs_data->hash_length));
-    if (result != 0) {
-        LOGE("Secure FS: error reading password hash.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = get_binary_file_contents(encrypted_fs_data->entropy, ENTROPY_MAX_SIZE,
-            encrypted_fs_entropy_file_src_name, &(encrypted_fs_data->entropy_length));
-    if (result != 0) {
-        LOGE("Secure FS: error reading ported entropy.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = ensure_path_unmounted("/data");
-    if (result != 0) {
-        LOGE("Secure FS: error unmounting data partition.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    return ENCRYPTED_FS_OK;
-}
-
-int restore_encrypted_fs_info(encrypted_fs_info *encrypted_fs_data) {
-    int result;
-    result = ensure_path_mounted("/data");
-    if (result != 0) {
-        LOGE("Secure FS: error mounting userdata partition.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    // Write the pre-generated secure FS key, password hash and salt.
-    result = set_binary_file_contents(encrypted_fs_data->key, ENCRYPTED_FS_KEY_SIZE,
-            encrypted_fs_key_file_name);
-    if (result != 0) {
-        LOGE("Secure FS: error writing generated file system key.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = set_binary_file_contents(encrypted_fs_data->salt, encrypted_fs_data->salt_length,
-        encrypted_fs_salt_file_name);
-    if (result != 0) {
-        LOGE("Secure FS: error writing file system salt.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = set_binary_file_contents(encrypted_fs_data->hash, encrypted_fs_data->hash_length,
-            encrypted_fs_hash_file_dst_name);
-    if (result != 0) {
-        LOGE("Secure FS: error writing password hash.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    result = set_binary_file_contents(encrypted_fs_data->entropy, encrypted_fs_data->entropy_length,
-            encrypted_fs_entropy_file_dst_name);
-    if (result != 0) {
-        LOGE("Secure FS: error writing ported entropy.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    // Set the secure FS properties to their respective values
-    result = write_encrypted_fs_boolean_property(encrypted_fs_enabled_property, encrypted_fs_data->mode);
-    if (result != 0) {
-        return result;
-    }
-
-    result = ensure_path_unmounted("/data");
-    if (result != 0) {
-        LOGE("Secure FS: error unmounting data partition.");
-        return ENCRYPTED_FS_ERROR;
-    }
-
-    return ENCRYPTED_FS_OK;
-}
diff --git a/encryptedfs_provisioning.h b/encryptedfs_provisioning.h
deleted file mode 100644
index 284605d..0000000
--- a/encryptedfs_provisioning.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2009 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 <stdio.h>
-
-#ifndef __ENCRYPTEDFS_PROVISIONING_H__
-#define __ENCRYPTEDFS_PROVISIONING_H__
-
-#define MODE_ENCRYPTED_FS_DISABLED    0
-#define MODE_ENCRYPTED_FS_ENABLED     1
-
-#define ENCRYPTED_FS_OK               0
-#define ENCRYPTED_FS_ERROR          (-1)
-
-#define ENCRYPTED_FS_KEY_SIZE        16
-#define ENCRYPTED_FS_SALT_SIZE       16
-#define ENCRYPTED_FS_MAX_HASH_SIZE  128
-#define ENTROPY_MAX_SIZE        4096
-
-struct encrypted_fs_info {
-    int mode;
-    char key[ENCRYPTED_FS_KEY_SIZE];
-    char salt[ENCRYPTED_FS_SALT_SIZE];
-    int salt_length;
-    char hash[ENCRYPTED_FS_MAX_HASH_SIZE];
-    int hash_length;
-    char entropy[ENTROPY_MAX_SIZE];
-    int entropy_length;
-};
-
-typedef struct encrypted_fs_info encrypted_fs_info;
-
-int read_encrypted_fs_info(encrypted_fs_info *secure_fs_data);
-
-int restore_encrypted_fs_info(encrypted_fs_info *secure_data);
-
-#endif /* __ENCRYPTEDFS_PROVISIONING_H__ */
-
diff --git a/recovery.c b/recovery.c
index 9ad075d..aebfba4 100644
--- a/recovery.c
+++ b/recovery.c
@@ -38,14 +38,12 @@
 #include "minzip/DirUtil.h"
 #include "roots.h"
 #include "recovery_ui.h"
-#include "encryptedfs_provisioning.h"
 
 static const struct option OPTIONS[] = {
   { "send_intent", required_argument, NULL, 's' },
   { "update_package", required_argument, NULL, 'u' },
   { "wipe_data", no_argument, NULL, 'w' },
   { "wipe_cache", no_argument, NULL, 'c' },
-  { "set_encrypted_filesystems", required_argument, NULL, 'e' },
   { "show_text", no_argument, NULL, 't' },
   { NULL, 0, NULL, 0 },
 };
@@ -114,26 +112,6 @@
  *    8g. finish_recovery() erases BCB
  *        -- after this, rebooting will (try to) restart the main system --
  * 9. main() calls reboot() to boot main system
- *
- * SECURE FILE SYSTEMS ENABLE/DISABLE
- * 1. user selects "enable encrypted file systems"
- * 2. main system writes "--set_encrypted_filesystems=on|off" to
- *    /cache/recovery/command
- * 3. main system reboots into recovery
- * 4. get_args() writes BCB with "boot-recovery" and
- *    "--set_encrypted_filesystems=on|off"
- *    -- after this, rebooting will restart the transition --
- * 5. read_encrypted_fs_info() retrieves encrypted file systems settings from /data
- *    Settings include: property to specify the Encrypted FS istatus and
- *    FS encryption key if enabled (not yet implemented)
- * 6. erase_volume() reformats /data
- * 7. erase_volume() reformats /cache
- * 8. restore_encrypted_fs_info() writes required encrypted file systems settings to /data
- *    Settings include: property to specify the Encrypted FS status and
- *    FS encryption key if enabled (not yet implemented)
- * 9. finish_recovery() erases BCB
- *    -- after this, rebooting will restart the main system --
- * 10. main() calls reboot() to boot main system
  */
 
 static const int MAX_ARG_LENGTH = 4096;
@@ -708,10 +686,7 @@
     int previous_runs = 0;
     const char *send_intent = NULL;
     const char *update_package = NULL;
-    const char *encrypted_fs_mode = NULL;
     int wipe_data = 0, wipe_cache = 0;
-    int toggle_secure_fs = 0;
-    encrypted_fs_info encrypted_fs_data;
 
     int arg;
     while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) {
@@ -721,7 +696,6 @@
         case 'u': update_package = optarg; break;
         case 'w': wipe_data = wipe_cache = 1; break;
         case 'c': wipe_cache = 1; break;
-        case 'e': encrypted_fs_mode = optarg; toggle_secure_fs = 1; break;
         case 't': ui_show_text(1); break;
         case '?':
             LOGE("Invalid command argument\n");
@@ -758,43 +732,7 @@
 
     int status = INSTALL_SUCCESS;
 
-    if (toggle_secure_fs) {
-        if (strcmp(encrypted_fs_mode,"on") == 0) {
-            encrypted_fs_data.mode = MODE_ENCRYPTED_FS_ENABLED;
-            ui_print("Enabling Encrypted FS.\n");
-        } else if (strcmp(encrypted_fs_mode,"off") == 0) {
-            encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED;
-            ui_print("Disabling Encrypted FS.\n");
-        } else {
-            ui_print("Error: invalid Encrypted FS setting.\n");
-            status = INSTALL_ERROR;
-        }
-
-        // Recovery strategy: if the data partition is damaged, disable encrypted file systems.
-        // This preventsthe device recycling endlessly in recovery mode.
-        if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) &&
-                (read_encrypted_fs_info(&encrypted_fs_data))) {
-            ui_print("Encrypted FS change aborted, resetting to disabled state.\n");
-            encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED;
-        }
-
-        if (status != INSTALL_ERROR) {
-            if (erase_volume("/data")) {
-                ui_print("Data wipe failed.\n");
-                status = INSTALL_ERROR;
-            } else if (erase_volume("/cache")) {
-                ui_print("Cache wipe failed.\n");
-                status = INSTALL_ERROR;
-            } else if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) &&
-                      (restore_encrypted_fs_info(&encrypted_fs_data))) {
-                ui_print("Encrypted FS change aborted.\n");
-                status = INSTALL_ERROR;
-            } else {
-                ui_print("Successfully updated Encrypted FS.\n");
-                status = INSTALL_SUCCESS;
-            }
-        }
-    } else if (update_package != NULL) {
+    if (update_package != NULL) {
         status = install_package(update_package);
         if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n");
     } else if (wipe_data) {
