summaryrefslogtreecommitdiffstats
path: root/src/local.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-11-24 11:08:25 +0100
committerPali Rohár <pali.rohar@gmail.com>2012-11-24 11:08:25 +0100
commit6ecc3e2a80757cdeb16ec717818ceeb23e3a6e28 (patch)
tree8deb691f1d34f6080d45d04b583b76cf09975eda /src/local.c
parent9164f331a37261602a2539cb1c47ecabfe4a8412 (diff)
download0xFFFF-6ecc3e2a80757cdeb16ec717818ceeb23e3a6e28.tar.bz2
local: Fix default value for usb_host_mode and root_device, fix align for mmc, remove empty dumps
Diffstat (limited to 'src/local.c')
-rw-r--r--src/local.c20
1 files changed, 15 insertions, 5 deletions
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);
}