summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ferguson <ferguson.david@gmail.com>2012-06-07 21:00:41 -0400
committerAndreas Blaesius <skate4life@gmx.de>2015-10-21 07:54:37 -0700
commit0a096cf07e835a910952b630de098a6d77e10c30 (patch)
treeea6598183453344ce217e163fd57b2910c83c65f
parent8b6bfea8494e3466a622eb69609d64e89ca425c8 (diff)
downloadandroid_system_extras-0a096cf07e835a910952b630de098a6d77e10c30.tar.gz
android_system_extras-0a096cf07e835a910952b630de098a6d77e10c30.tar.bz2
android_system_extras-0a096cf07e835a910952b630de098a6d77e10c30.zip
ext4_utils: add BoardConfig define to suppress EMMC-corrupting wipe command
If BOARD_SUPPRESS_EMMC_WIPE is true, the EMMC wipe command will not be issued. This works around a bug in some firmware revisions of Samsung EMMC's that permanently damages the device when the wipe command is issued. For affected devices with kernel source, MMC_CAP_ERASE should be removed from the kernel instead. This is only part of the solution but it does handle the "flashing CM9 for the first time on an unsafe kernel" situation. Change-Id: Ie4e31f9268a65218e5d344ae3068b021790fc33c
-rw-r--r--ext4_utils/Android.mk10
-rw-r--r--ext4_utils/wipe.c9
2 files changed, 17 insertions, 2 deletions
diff --git a/ext4_utils/Android.mk b/ext4_utils/Android.mk
index 31a4b711..4a41d8f5 100644
--- a/ext4_utils/Android.mk
+++ b/ext4_utils/Android.mk
@@ -70,6 +70,11 @@ LOCAL_SHARED_LIBRARIES := \
libsparse \
libz
LOCAL_CFLAGS := -DREAL_UUID
+
+ifeq ($(BOARD_SUPPRESS_EMMC_WIPE),true)
+ LOCAL_CFLAGS += -DSUPPRESS_EMMC_WIPE
+endif
+
include $(BUILD_SHARED_LIBRARY)
@@ -79,6 +84,11 @@ LOCAL_SRC_FILES := $(libext4_utils_src_files) \
LOCAL_MODULE := libext4_utils_static
LOCAL_STATIC_LIBRARIES := \
libsparse_static
+
+ifeq ($(BOARD_SUPPRESS_EMMC_WIPE),true)
+ LOCAL_CFLAGS += -DSUPPRESS_EMMC_WIPE
+endif
+
include $(BUILD_STATIC_LIBRARY)
diff --git a/ext4_utils/wipe.c b/ext4_utils/wipe.c
index 002e0213..f8af756d 100644
--- a/ext4_utils/wipe.c
+++ b/ext4_utils/wipe.c
@@ -34,6 +34,7 @@
int wipe_block_device(int fd, s64 len)
{
+#ifndef SUPPRESS_EMMC_WIPE
u64 range[2];
int ret;
@@ -47,7 +48,7 @@ int wipe_block_device(int fd, s64 len)
range[1] = len;
ret = ioctl(fd, BLKSECDISCARD, &range);
if (ret < 0) {
-#endif
+#endif /* NO_SECURE_DISCARD */
range[0] = 0;
range[1] = len;
ret = ioctl(fd, BLKDISCARD, &range);
@@ -60,8 +61,12 @@ int wipe_block_device(int fd, s64 len)
}
#ifndef NO_SECURE_DISCARD
}
-#endif
+#endif /* NO_SECURE_DISCARD */
return 0;
+#else
+ warn("Wipe via secure discard suppressed due to bug in EMMC firmware\n");
+ return 1;
+#endif /* SUPPRESS_EMMC_WIPE */
}
#else /* __linux__ */