summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 081b710)
raw | patch | inline | side by side (parent: 081b710)
author | Aaron Wisner <awisner@google.com> | |
Wed, 1 Aug 2018 17:57:20 +0000 (12:57 -0500) | ||
committer | Aaron Wisner <awisner@google.com> | |
Thu, 2 Aug 2018 22:47:38 +0000 (17:47 -0500) |
- Make RCString() static
- Add clearer error message for 0 length upload error
- Fix regex hex matching for partition-size
- Move ZLP packet checking to SparseWriteCallback()
Test: build fastboot on glinux
Change-Id: I51a040e07b9698a41f64b35a9e2baa8d575527a9
- Add clearer error message for 0 length upload error
- Fix regex hex matching for partition-size
- Move ZLP packet checking to SparseWriteCallback()
Test: build fastboot on glinux
Change-Id: I51a040e07b9698a41f64b35a9e2baa8d575527a9
fastboot/fastboot_driver.cpp | patch | blob | history | |
fastboot/fastboot_driver.h | patch | blob | history |
index aabc620d431a00cd7d663ae9cd870973e30b849a..55ca65d3fafcc65fe70e61b9c71df217714b2ab4 100644 (file)
@@ -134,7 +134,7 @@ RetCode FastBootDriver::Partitions(std::vector<std::tuple<std::string, uint32_t>
return ret;
}
- std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:d:]]+)");
+ std::regex reg("partition-size[[:s:]]*:[[:s:]]*([[:w:]]+)[[:s:]]*:[[:s:]]*0x([[:xdigit:]]+)");
std::smatch sm;
for (auto& s : all) {
@@ -264,11 +264,16 @@ RetCode FastBootDriver::Upload(const std::string& outfile, std::string* response
std::vector<std::string>* info) {
RetCode ret;
int dsize;
- if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize)) || dsize == 0) {
- error_ = "Upload request failed";
+ if ((ret = RawCommand(Commands::UPLOAD, response, info, &dsize))) {
+ error_ = "Upload request failed: " + error_;
return ret;
}
+ if (!dsize) {
+ error_ = "Upload request failed, device reports 0 bytes available";
+ return BAD_DEV_RESP;
+ }
+
std::vector<char> data;
data.resize(dsize);
}
RetCode FastBootDriver::SendBuffer(const void* buf, size_t size) {
+ // ioctl on 0-length buffer causes freezing
if (!size) {
- return SUCCESS;
+ return BAD_ARG;
}
-
// Write the buffer
ssize_t tmp = transport->Write(buf, size);
@@ -521,7 +526,7 @@ int FastBootDriver::SparseWriteCallback(std::vector<char>& tpbuf, const char* da
// Now we need to send a multiple of chunk size
size_t nchunks = (len - total) / TRANSPORT_CHUNK_SIZE;
size_t nbytes = TRANSPORT_CHUNK_SIZE * nchunks;
- if (SendBuffer(data + total, nbytes)) {
+ if (nbytes && SendBuffer(data + total, nbytes)) { // Don't send a ZLP
error_ = ErrnoStr("Send failed in SparseWriteCallback()");
return -1;
}
index 9fdd31700c87b254905eab657a1147cd68f0028e..e8711cba2d46d6e8b19a67c5833b347372838003 100644 (file)
/* HELPERS */
void SetInfoCallback(std::function<void(std::string&)> info);
- const std::string RCString(RetCode rc);
+ static const std::string RCString(RetCode rc);
std::string Error();
RetCode WaitForDisconnect();