am bb0d0721: am 94938c9d: am ed2e672f: Merge "Print strerror for file read errors during flashing"
* commit 'bb0d0721e6bc5dcedc9bbbac0ea8fa4e57f487ad':
Print strerror for file read errors during flashing
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 2a63905..898d452 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -157,6 +157,7 @@
char *data;
int sz;
int fd;
+ int errno_tmp;
data = 0;
fd = open(fn, O_RDONLY);
@@ -177,8 +178,10 @@
return data;
oops:
+ errno_tmp = errno;
close(fd);
if(data != 0) free(data);
+ errno = errno_tmp;
return 0;
}
#endif
@@ -313,7 +316,7 @@
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;
}
@@ -333,7 +336,7 @@
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;
}
}
@@ -579,7 +582,7 @@
} 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);
}
}
@@ -607,7 +610,7 @@
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'");
@@ -677,12 +680,12 @@
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);
@@ -695,7 +698,7 @@
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);
}
@@ -865,7 +868,7 @@
} 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");