summaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorMatt Gumbel <matthew.k.gumbel@intel.com>2011-12-08 11:59:38 -0800
committerAndrew Boie <andrew.p.boie@intel.com>2012-07-26 10:19:05 -0700
commit64ba258b7a17fd5f0abd788c1b021ad45ad732b9 (patch)
treed0568840729b46027d0bde0d4b774d53d73fcd95 /fastboot
parentec7d9dc713322bd41b1e348c0ea3b1304a13dba9 (diff)
downloadcore-64ba258b7a17fd5f0abd788c1b021ad45ad732b9.tar.gz
core-64ba258b7a17fd5f0abd788c1b021ad45ad732b9.tar.bz2
core-64ba258b7a17fd5f0abd788c1b021ad45ad732b9.zip
Print strerror for file read errors during flashing
Change-Id: I7390867abd00036f19eb4d1a1ce23aa0aca50674 Signed-off-by: Matt Gumbel <matthew.k.gumbel@intel.com> Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/fastboot.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index ff9917300..dc9bfa4bb 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -158,6 +158,7 @@ void *load_file(const char *fn, unsigned *_sz)
char *data;
int sz;
int fd;
+ int errno_tmp;
data = 0;
fd = open(fn, O_RDONLY);
@@ -178,8 +179,10 @@ void *load_file(const char *fn, unsigned *_sz)
return data;
oops:
+ errno_tmp = errno;
close(fd);
if(data != 0) free(data);
+ errno = errno_tmp;
return 0;
}
#endif
@@ -300,7 +303,7 @@ void *load_bootable_image(unsigned page_size, const char *kernel, const char *ra
kdata = load_file(kernel, &ksize);
if(kdata == 0) {
- fprintf(stderr, "cannot load '%s'\n", kernel);
+ fprintf(stderr, "cannot load '%s': %s\n", kernel, strerror(errno));
return 0;
}
@@ -320,7 +323,7 @@ void *load_bootable_image(unsigned page_size, const char *kernel, const char *ra
if(ramdisk) {
rdata = load_file(ramdisk, &rsize);
if(rdata == 0) {
- fprintf(stderr,"cannot load '%s'\n", ramdisk);
+ fprintf(stderr,"cannot load '%s': %s\n", ramdisk, strerror(errno));
return 0;
}
}
@@ -566,7 +569,7 @@ void do_flash(usb_handle *usb, const char *pname, const char *fname)
} else {
unsigned int sz;
data = load_file(fname, &sz);
- if (data == 0) die("cannot load '%s'\n", fname);
+ if (data == 0) die("cannot load '%s': %s\n", fname, strerror(errno));
fb_queue_flash(pname, data, sz);
}
}
@@ -594,7 +597,7 @@ void do_update(char *fn)
fb_queue_query_save("product", cur_product, sizeof(cur_product));
zdata = load_file(fn, &zsize);
- if (zdata == 0) die("failed to load '%s'", fn);
+ if (zdata == 0) die("failed to load '%s': %s", fn, strerror(errno));
zip = init_zipfile(zdata, zsize);
if(zip == 0) die("failed to access zipdata in '%s'");
@@ -664,12 +667,12 @@ void do_flashall(void)
fname = find_item("info", product);
if (fname == 0) die("cannot find android-info.txt");
data = load_file(fname, &sz);
- if (data == 0) die("could not load android-info.txt");
+ if (data == 0) die("could not load android-info.txt: %s", strerror(errno));
setup_requirements(data, sz);
fname = find_item("boot", product);
data = load_file(fname, &sz);
- if (data == 0) die("could not load boot.img");
+ if (data == 0) die("could not load boot.img: %s", strerror(errno));
do_send_signature(fname);
fb_queue_flash("boot", data, sz);
@@ -682,7 +685,7 @@ void do_flashall(void)
fname = find_item("system", product);
data = load_file(fname, &sz);
- if (data == 0) die("could not load system.img");
+ if (data == 0) die("could not load system.img: %s", strerror(errno));
do_send_signature(fname);
fb_queue_flash("system", data, sz);
}
@@ -849,7 +852,7 @@ int main(int argc, char **argv)
} else if(!strcmp(*argv, "signature")) {
require(2);
data = load_file(argv[1], &sz);
- if (data == 0) die("could not load '%s'", argv[1]);
+ if (data == 0) die("could not load '%s': %s", argv[1], strerror(errno));
if (sz != 256) die("signature must be 256 bytes");
fb_queue_download("signature", data, sz);
fb_queue_command("signature", "installing signature");