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>
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index ff99173..dc9bfa4 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -158,6 +158,7 @@
char *data;
int sz;
int fd;
+ int errno_tmp;
data = 0;
fd = open(fn, O_RDONLY);
@@ -178,8 +179,10 @@
return data;
oops:
+ errno_tmp = errno;
close(fd);
if(data != 0) free(data);
+ errno = errno_tmp;
return 0;
}
#endif
@@ -300,7 +303,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;
}
@@ -320,7 +323,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;
}
}
@@ -566,7 +569,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);
}
}
@@ -594,7 +597,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'");
@@ -664,12 +667,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);
@@ -682,7 +685,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);
}
@@ -849,7 +852,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");