diff options
author | Yabin Cui <yabinc@google.com> | 2021-05-05 13:34:59 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2021-05-05 13:38:52 -0700 |
commit | 554f3bbf0a582617c3d466ed5839e7eaf218b74b (patch) | |
tree | 82f886e8519ed7d4ea0ae812e7f7e7f84793e2bc /simpleperf/cmd_record.cpp | |
parent | ac2e71ce6971ad3b61bcafb8d0c598fc5f94d043 (diff) | |
download | extras-554f3bbf0a582617c3d466ed5839e7eaf218b74b.tar.gz |
simpleperf: improve error msg for output file.
When writing to a read-only file system, the error msg is improved as
below:
$ simpleperf record sleep 1
Can't create output file in directory .: Read-only file system
Bug: 187126442
Test: run simpleperf_unit_test
Change-Id: I5c61514aeba1bfc73e9bf95f625adf76e7056fa0
Diffstat (limited to 'simpleperf/cmd_record.cpp')
-rw-r--r-- | simpleperf/cmd_record.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp index b9fd6657..3d8deec0 100644 --- a/simpleperf/cmd_record.cpp +++ b/simpleperf/cmd_record.cpp @@ -458,7 +458,13 @@ bool RecordCommand::Run(const std::vector<std::string>& args) { if (!AdjustPerfEventLimit()) { return false; } - ScopedTempFiles scoped_temp_files(android::base::Dirname(record_filename_)); + std::unique_ptr<ScopedTempFiles> scoped_temp_files = + ScopedTempFiles::Create(android::base::Dirname(record_filename_)); + if (!scoped_temp_files) { + PLOG(ERROR) << "Can't create output file in directory " + << android::base::Dirname(record_filename_); + return false; + } if (!app_package_name_.empty() && !in_app_context_) { // Some users want to profile non debuggable apps on rooted devices. If we use run-as, // it will be impossible when using --app. So don't switch to app's context when we are |