diff options
| author | Alex Deymo <deymo@google.com> | 2016-06-15 16:31:04 -0700 |
|---|---|---|
| committer | Alex Deymo <deymo@google.com> | 2016-06-16 18:44:26 +0000 |
| commit | 72a68d829f6b0bc97368c64d35a860465716018c (patch) | |
| tree | 09b0a043fa26ebee5c3a85876f8baa9ed63e3a50 | |
| parent | ed9cc18eb7746c7f65a68e15a276472aa2176ab1 (diff) | |
Show the name of the BLK* ioctl failure instead of the number.
The ioctl number is normally tied to the platform and doesn't allow a
quick debug of what was supported. This patch prints the name instead
of the error number.
Bug: 28744609
TEST=Deployed an update on Android and saw the ioctl names instead of numbers.
Change-Id: Ie3a69841f3bf9cd719ead0cdc80e82d2c4725c68
| -rw-r--r-- | payload_consumer/delta_performer.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc index d25b829c..09b19fbe 100644 --- a/payload_consumer/delta_performer.cc +++ b/payload_consumer/delta_performer.cc @@ -140,22 +140,26 @@ bool DiscardPartitionTail(FileDescriptorPtr fd, uint64_t data_size) { if (!part_size || part_size <= data_size) return false; - const vector<int> requests = { - BLKSECDISCARD, - BLKDISCARD, + struct blkioctl_request { + int number; + const char* name; + }; + const vector<blkioctl_request> blkioctl_requests = { + {BLKSECDISCARD, "BLKSECDISCARD"}, + {BLKDISCARD, "BLKDISCARD"}, #ifdef BLKZEROOUT - BLKZEROOUT, + {BLKZEROOUT, "BLKZEROOUT"}, #endif }; - for (int request : requests) { + for (const auto& req : blkioctl_requests) { int error = 0; - if (fd->BlkIoctl(request, data_size, part_size - data_size, &error) && + if (fd->BlkIoctl(req.number, data_size, part_size - data_size, &error) && error == 0) { return true; } LOG(WARNING) << "Error discarding the last " << (part_size - data_size) / 1024 << " KiB using ioctl(" - << request << ")"; + << req.name << ")"; } return false; } |
