diff options
author | Jaegeuk Kim <jaegeuk@google.com> | 2019-02-13 15:24:01 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@google.com> | 2019-02-13 22:11:36 -0800 |
commit | a2df793a48e7aebc45ed8cc2ef487d30203c4c40 (patch) | |
tree | dec1590dd3b1e37db9d7a0d4d44696abc3032cb5 /ext4_utils | |
parent | 03fcd4502b367ed3c975ecbb076bdc8309887ece (diff) | |
download | extras-a2df793a48e7aebc45ed8cc2ef487d30203c4c40.tar.gz |
wipe: guarantee zeros after wipe out partitions
Stale data in the partition can bypass formatting by fs_mgr and cause filesystem
unmountable.
Bug: 122989894
Change-Id: Id2aa4baefeb8308ce14eeaa7790a1aab35e522aa
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Diffstat (limited to 'ext4_utils')
-rw-r--r-- | ext4_utils/Android.bp | 1 | ||||
-rw-r--r-- | ext4_utils/wipe.cpp | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/ext4_utils/Android.bp b/ext4_utils/Android.bp index f8bb310e..e9c5965f 100644 --- a/ext4_utils/Android.bp +++ b/ext4_utils/Android.bp @@ -16,6 +16,7 @@ cc_library { ], export_include_dirs: ["include"], shared_libs: [ + "libbase", "libsparse", "libz", ], diff --git a/ext4_utils/wipe.cpp b/ext4_utils/wipe.cpp index 7bda71c1..c2db3353 100644 --- a/ext4_utils/wipe.cpp +++ b/ext4_utils/wipe.cpp @@ -18,6 +18,8 @@ #include "ext4_utils/ext4_utils.h" +#include <android-base/file.h> + #if WIPE_IS_SUPPORTED #if defined(__linux__) @@ -54,6 +56,13 @@ int wipe_block_device(int fd, s64 len) warn("Discard failed\n"); return 1; } else { + char buf[4096] = {0}; + + if (!android::base::WriteFully(fd, buf, 4096)) { + warn("Writing zeros failed\n"); + return 1; + } + fsync(fd); warn("Wipe via secure discard failed, used discard instead\n"); return 0; } |