| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2015 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 16 |  | 
|  | 17 | #include "update_engine/payload_generator/raw_filesystem.h" | 
|  | 18 |  | 
| Amin Hassani | 232f8f9 | 2019-01-14 16:15:31 -0800 | [diff] [blame] | 19 | #include <memory> | 
|  | 20 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 21 | #include "update_engine/common/utils.h" | 
| Alex Deymo | 1beda78 | 2015-06-07 23:01:25 +0200 | [diff] [blame] | 22 | #include "update_engine/payload_generator/extent_ranges.h" | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 23 | #include "update_engine/update_metadata.pb.h" | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 24 |  | 
|  | 25 | using std::unique_ptr; | 
|  | 26 |  | 
|  | 27 | namespace chromeos_update_engine { | 
|  | 28 |  | 
| Amin Hassani | 232f8f9 | 2019-01-14 16:15:31 -0800 | [diff] [blame] | 29 | unique_ptr<RawFilesystem> RawFilesystem::Create(const std::string& filename, | 
|  | 30 | uint64_t block_size, | 
|  | 31 | uint64_t block_count) { | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 32 | unique_ptr<RawFilesystem> result(new RawFilesystem()); | 
|  | 33 | result->filename_ = filename; | 
|  | 34 | result->block_size_ = block_size; | 
|  | 35 | result->block_count_ = block_count; | 
|  | 36 | return result; | 
|  | 37 | } | 
|  | 38 |  | 
|  | 39 | size_t RawFilesystem::GetBlockSize() const { | 
|  | 40 | return block_size_; | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | size_t RawFilesystem::GetBlockCount() const { | 
|  | 44 | return block_count_; | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | bool RawFilesystem::GetFiles(std::vector<File>* files) const { | 
|  | 48 | files->clear(); | 
|  | 49 | File file; | 
|  | 50 | file.name = filename_; | 
| Amin Hassani | 232f8f9 | 2019-01-14 16:15:31 -0800 | [diff] [blame] | 51 | file.extents = {ExtentForRange(0, block_count_)}; | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 52 | files->push_back(file); | 
|  | 53 | return true; | 
|  | 54 | } | 
|  | 55 |  | 
|  | 56 | }  // namespace chromeos_update_engine |