ext4_utils: Add support for wipe option, and wipe by default in recovery
Adds a -w option to make_ext4fs, which will attempt to use the
BLKSECDISCARD ioctl to erase the partition in order to avoid
leaving old data where it could be recovered, and to improve
wear levelling after a reformat.
Also causes factory reset through recovery to do a wipe.
Change-Id: Ibe34bbd84552e526be6bd041024a950806aca6b4
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index 5742261..a87529d 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -246,12 +246,12 @@
{
reset_ext4fs_info();
info.len = len;
- return make_ext4fs_internal(filename, NULL, NULL, 0, 0, 0, 0);
+ return make_ext4fs_internal(filename, NULL, NULL, 0, 0, 0, 0, 1);
}
int make_ext4fs_internal(const char *filename, const char *directory,
char *mountpoint, int android, int gzip, int sparse,
- int crc)
+ int crc, int wipe)
{
u32 root_inode_num;
u16 root_mode;
@@ -349,7 +349,7 @@
aux_info.sb->s_blocks_count_lo - aux_info.sb->s_free_blocks_count_lo,
aux_info.sb->s_blocks_count_lo);
- write_ext4_image(filename, gzip, sparse, crc);
+ write_ext4_image(filename, gzip, sparse, crc, wipe);
return 0;
}