diff options
author | Justin DeMartino <jjdemartino@google.com> | 2020-10-14 19:39:53 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-10-14 19:39:53 +0000 |
commit | 0d11af03e43f110b0bb160f7e20436d0043e3038 (patch) | |
tree | 48f8bcca856276ec73a86dd3fb26143d3ca64578 /logcat/logcat.cpp | |
parent | 075666ebd0dee8d0c4a2efa54f7c324a3f67ee2a (diff) | |
parent | a6c01e4e98d2b343dcecfc99611e2e6250c730db (diff) |
Merge changes from topic "SP1A.200921.001" into s-keystone-qcom-dev
* changes:
fs_mgr: adb-remount-test.sh: filter out more administrivia mounts.
Merge SP1A.200921.001 Change-Id: I90b97c4e9fb10b1f45e74def404823eed5b1aaa8
Diffstat (limited to 'logcat/logcat.cpp')
-rw-r--r-- | logcat/logcat.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index d15fa2be7..6b7e016a4 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -64,6 +64,7 @@ using android::base::ParseByteCount; using android::base::ParseUint; using android::base::Split; using android::base::StringPrintf; +using android::base::WriteFully; class Logcat { public: @@ -616,15 +617,15 @@ int Logcat::Run(int argc, char** argv) { if (long_options[option_index].name == wrap_str) { mode |= ANDROID_LOG_WRAP | ANDROID_LOG_NONBLOCK; // ToDo: implement API that supports setting a wrap timeout - size_t dummy = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT; - if (optarg && (!ParseUint(optarg, &dummy) || dummy < 1)) { + size_t timeout = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT; + if (optarg && (!ParseUint(optarg, &timeout) || timeout < 1)) { error(EXIT_FAILURE, 0, "%s %s out of range.", long_options[option_index].name, optarg); } - if (dummy != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) { + if (timeout != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) { fprintf(stderr, "WARNING: %s %u seconds, ignoring %zu\n", long_options[option_index].name, ANDROID_LOG_WRAP_DEFAULT_TIMEOUT, - dummy); + timeout); } break; } @@ -864,8 +865,7 @@ int Logcat::Run(int argc, char** argv) { if (consolePipe) { // need the trailing '\0' - if (!android::base::WriteFully(fd, pipePurpose.c_str(), - pipePurpose.size() + 1)) { + if (!WriteFully(fd, pipePurpose.c_str(), pipePurpose.size() + 1)) { close(fd); return EXIT_FAILURE; } @@ -1064,19 +1064,23 @@ int Logcat::Run(int argc, char** argv) { if (getLogSize) { long size = android_logger_get_log_size(logger); long readable = android_logger_get_log_readable_size(logger); + long consumed = android_logger_get_log_consumed_size(logger); if (size < 0 || readable < 0) { ReportErrorName(buffer_name, security_buffer_selected, &get_size_failures); } else { auto size_format = format_of_size(size); auto readable_format = format_of_size(readable); + auto consumed_format = format_of_size(consumed); std::string str = android::base::StringPrintf( - "%s: ring buffer is %lu %sB (%lu %sB consumed)," + "%s: ring buffer is %lu %sB (%lu %sB consumed, %lu %sB readable)," " max entry is %d B, max payload is %d B\n", - buffer_name, size_format.first, size_format.second, readable_format.first, - readable_format.second, (int)LOGGER_ENTRY_MAX_LEN, - (int)LOGGER_ENTRY_MAX_PAYLOAD); - TEMP_FAILURE_RETRY(write(output_fd_.get(), str.data(), str.length())); + buffer_name, size_format.first, size_format.second, consumed_format.first, + consumed_format.second, readable_format.first, readable_format.second, + (int)LOGGER_ENTRY_MAX_LEN, (int)LOGGER_ENTRY_MAX_PAYLOAD); + if (!WriteFully(output_fd_, str.data(), str.length())) { + error(EXIT_FAILURE, errno, "Failed to write to output fd"); + } } } } @@ -1146,7 +1150,9 @@ int Logcat::Run(int argc, char** argv) { if (*cp == '\n') ++cp; size_t len = strlen(cp); - TEMP_FAILURE_RETRY(write(output_fd_.get(), cp, len)); + if (!WriteFully(output_fd_, cp, len)) { + error(EXIT_FAILURE, errno, "Failed to write to output fd"); + } return EXIT_SUCCESS; } @@ -1190,7 +1196,9 @@ If you have enabled significant logging, look into using the -G option to increa PrintDividers(log_msg.id(), printDividers); if (print_binary_) { - TEMP_FAILURE_RETRY(write(output_fd_.get(), &log_msg, log_msg.len())); + if (!WriteFully(output_fd_, &log_msg, log_msg.len())) { + error(EXIT_FAILURE, errno, "Failed to write to output fd"); + } } else { ProcessBuffer(&log_msg); } |