From aa3c3d429bbbe12ee30ade7edd683d6e4884cb45 Mon Sep 17 00:00:00 2001 From: Pawit Pornkitprasan Date: Tue, 6 Dec 2011 16:19:32 +0700 Subject: [PATCH] Respect volume length when formatting ext4 when restoring This is needed for device encryption to work properly (there must be space for a 16 KB footer at the end of the partition, which is usually specified by the length option). And yes, the old signature of make_ext4fs was wrong, but worked anyway because the related header was not included and the compiler let it pass an as implicit delcaration. Change-Id: Ied7ec70bebc120cc2917771f59eeaeb7ea76bf8d --- extendedcommands.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extendedcommands.c b/extendedcommands.c index af67c3e..43d449a 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -25,6 +25,7 @@ #include "cutils/properties.h" #include "firmware.h" #include "install.h" +#include "make_ext4fs.h" #include "minui/minui.h" #include "minzip/DirUtil.h" #include "roots.h" @@ -507,8 +508,13 @@ int format_device(const char *device, const char *path, const char *fs_type) { } if (strcmp(fs_type, "ext4") == 0) { + int length = 0; + if (strcmp(v->fs_type, "ext4") == 0) { + // Our desired filesystem matches the one in fstab, respect v->length + length = v->length; + } reset_ext4fs_info(); - int result = make_ext4fs(device, NULL, NULL, 0, 0, 0); + int result = make_ext4fs(device, length); if (result != 0) { LOGE("format_volume: make_extf4fs failed on %s\n", device); return -1;