diff options
author | Amin Hassani <ahassani@chromium.org> | 2020-09-16 11:19:28 -0700 |
---|---|---|
committer | Amin Hassani <ahassani@chromium.org> | 2020-09-17 10:17:36 -0700 |
commit | e53b39b8b9c5c0871841bbbb86f23657c0b7f91b (patch) | |
tree | 12746e5e7e4716ba7fc94d3ed5c1a36c4d47d474 /common/file_fetcher.cc | |
parent | a02a1f1dc837f22226499d9856a949fb180d099a (diff) | |
parent | 9956320ffa4edb340d20bd7f3c852a9e87437bd3 (diff) |
update_engine: Merge remote-tracking branch 'cros/upstream' into cros/master
Done with:
git merge cros/upstream --commit -s recursive
- Added EC key support and its unittests.
- Resolved a conlict on error codes. Since Android versions are not
uploading any UMA metrics, I gave the priority to the Android version
Since they can't be changed.
- Changed the openssl functions to get1 version (from get0) version
because of a current issue with gale. Once the issue is resolved we
need to change them back.
- Some remaining styling issues fixed by clang-format
BUG=b:163153182
TEST=CQ passes
TEST=unittests
Change-Id: Ib95034422b92433ce26e28336bc4806b34910d38
Diffstat (limited to 'common/file_fetcher.cc')
-rw-r--r-- | common/file_fetcher.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/common/file_fetcher.cc b/common/file_fetcher.cc index 3836e548..7134fd69 100644 --- a/common/file_fetcher.cc +++ b/common/file_fetcher.cc @@ -43,8 +43,9 @@ namespace chromeos_update_engine { // static bool FileFetcher::SupportedUrl(const string& url) { // Note that we require the file path to start with a "/". - return base::StartsWith( - url, "file:///", base::CompareCase::INSENSITIVE_ASCII); + return ( + base::StartsWith(url, "file:///", base::CompareCase::INSENSITIVE_ASCII) || + base::StartsWith(url, "fd://", base::CompareCase::INSENSITIVE_ASCII)); } FileFetcher::~FileFetcher() { @@ -67,12 +68,20 @@ void FileFetcher::BeginTransfer(const string& url) { return; } - string file_path = url.substr(strlen("file://")); - stream_ = - brillo::FileStream::Open(base::FilePath(file_path), - brillo::Stream::AccessMode::READ, - brillo::FileStream::Disposition::OPEN_EXISTING, - nullptr); + string file_path; + + if (base::StartsWith(url, "fd://", base::CompareCase::INSENSITIVE_ASCII)) { + int fd = std::stoi(url.substr(strlen("fd://"))); + file_path = url; + stream_ = brillo::FileStream::FromFileDescriptor(fd, false, nullptr); + } else { + file_path = url.substr(strlen("file://")); + stream_ = + brillo::FileStream::Open(base::FilePath(file_path), + brillo::Stream::AccessMode::READ, + brillo::FileStream::Disposition::OPEN_EXISTING, + nullptr); + } if (!stream_) { LOG(ERROR) << "Couldn't open " << file_path; @@ -183,5 +192,4 @@ void FileFetcher::CleanUp() { transfer_in_progress_ = false; transfer_paused_ = false; } - } // namespace chromeos_update_engine |