From 8f132ed870b4b83727d59f8019b8fabe49fe8ed4 Mon Sep 17 00:00:00 2001 From: Ken Sumrall Date: Fri, 14 Jan 2011 18:55:05 -0800 Subject: Reserve the last 16 Kbytes of /data for the crypto footer. When formatting /data, if it's an ext4 filesystem, reserve the last 16 Kbytes for the crypto footer. Change-Id: I7b401d851ee87732e5da5860df0287a1c331c5b7 --- roots.c | 8 ++++++-- updater/install.c | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/roots.c b/roots.c index 92ce78950..5731d7407 100644 --- a/roots.c +++ b/roots.c @@ -238,8 +238,12 @@ int format_volume(const char* volume) { } if (strcmp(v->fs_type, "ext4") == 0) { - reset_ext4fs_info(); - int result = make_ext4fs(v->device, NULL, NULL, 0, 0, 0, 0); + s64 len = 0; + + if (strcmp(volume, "/data") == 0) { + len = -16384; /* Reserve 16 Kbytes for the crypto footer */ + } + int result = make_ext4fs(v->device, len); if (result != 0) { LOGE("format_volume: make_extf4fs failed on %s\n", v->device); return -1; diff --git a/updater/install.c b/updater/install.c index 656c60790..6a7996467 100644 --- a/updater/install.c +++ b/updater/install.c @@ -177,19 +177,23 @@ done: } -// format(fs_type, partition_type, location) +// format(fs_type, partition_type, location, fs_size) // -// fs_type="yaffs2" partition_type="MTD" location=partition -// fs_type="ext4" partition_type="EMMC" location=device +// fs_type="yaffs2" partition_type="MTD" location=partition fs_size= +// fs_type="ext4" partition_type="EMMC" location=device fs_size= +// if fs_size == 0, then make_ext4fs uses the entire partition. +// if fs_size > 0, that is the size to use +// if fs_size < 0, then reserve that many bytes at the end of the partition Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { char* result = NULL; - if (argc != 3) { - return ErrorAbort(state, "%s() expects 3 args, got %d", name, argc); + if (argc != 4) { + return ErrorAbort(state, "%s() expects 4 args, got %d", name, argc); } char* fs_type; char* partition_type; char* location; - if (ReadArgs(state, argv, 3, &fs_type, &partition_type, &location) < 0) { + char* fs_size; + if (ReadArgs(state, argv, 4, &fs_type, &partition_type, &location, &fs_size) < 0) { return NULL; } @@ -236,8 +240,7 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { result = location; #ifdef USE_EXT4 } else if (strcmp(fs_type, "ext4") == 0) { - reset_ext4fs_info(); - int status = make_ext4fs(location, NULL, NULL, 0, 0, 0, 0); + int status = make_ext4fs(location, atoll(fs_size)); if (status != 0) { fprintf(stderr, "%s: make_ext4fs failed (%d) on %s", name, status, location); -- cgit v1.2.3