From 6ecc3e2a80757cdeb16ec717818ceeb23e3a6e28 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 24 Nov 2012 11:08:25 +0100 Subject: local: Fix default value for usb_host_mode and root_device, fix align for mmc, remove empty dumps --- src/local.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/local.c') diff --git a/src/local.c b/src/local.c index b909f86..1cd9c1d 100644 --- a/src/local.c +++ b/src/local.c @@ -44,8 +44,8 @@ static char nolo_ver[256]; static char sw_ver[256]; static char content_ver[256]; static char rd_mode[256]; -static int usb_host_mode; -static int root_device; +static int usb_host_mode = -1; +static int root_device = -1; #define min(a, b) (a < b ? a : b) #define local_cal_copy(dest, from, len) strncpy(dest, from, min(len, sizeof(dest)-1)) @@ -57,6 +57,8 @@ static void local_cal_parse(void) { struct cal * cal = NULL; char buf[128]; + printf("Reading CAL...\n"); + if ( cal_init(&cal) < 0 || ! cal ) return; @@ -294,10 +296,18 @@ int local_dump_image(enum image_type image, const char * file) { if ( addr[nlen-1] != 0xFF ) break; - if ( ( nlen & ( ( 1ULL << 7 ) - 1 ) ) != 0 ) - nlen = ((nlen >> 7) + 1) << 7; + if ( image == IMAGE_MMC ) + align = 8; + else + align = 7; + + if ( ( nlen & ( ( 1ULL << align ) - 1 ) ) != 0 ) + nlen = ((nlen >> align) + 1) << align; - if ( nlen != len ) { + if ( nlen == 0 ) { + printf("File %s is empty, removing it...\n", file); + unlink(file); + } else if ( nlen != len ) { printf("Truncating file %s to %d bytes...\n", file, (int)nlen); ftruncate(fd, nlen); } -- cgit v1.2.3