| 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 | #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ | 
 | 18 | #define UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ | 
 | 19 |  | 
 | 20 | // A fake filesystem interface implementation allowing the user to add arbitrary | 
 | 21 | // files/metadata. | 
 | 22 |  | 
 | 23 | #include "update_engine/payload_generator/filesystem_interface.h" | 
 | 24 |  | 
 | 25 | #include <string> | 
 | 26 | #include <vector> | 
 | 27 |  | 
 | 28 | #include "update_engine/update_metadata.pb.h" | 
 | 29 |  | 
 | 30 | namespace chromeos_update_engine { | 
 | 31 |  | 
 | 32 | class FakeFilesystem : public FilesystemInterface { | 
 | 33 |  public: | 
 | 34 |   FakeFilesystem(uint64_t block_size, uint64_t block_count); | 
 | 35 |   virtual ~FakeFilesystem() = default; | 
 | 36 |  | 
 | 37 |   // FilesystemInterface overrides. | 
 | 38 |   size_t GetBlockSize() const override; | 
 | 39 |   size_t GetBlockCount() const override; | 
 | 40 |   bool GetFiles(std::vector<File>* files) const override; | 
| Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 41 |   bool LoadSettings(brillo::KeyValueStore* store) const override; | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 42 |  | 
 | 43 |   // Fake methods. | 
 | 44 |  | 
 | 45 |   // Add a file to the list of fake files. | 
| Chih-Hung Hsieh | 5c6bb1d | 2016-07-27 13:33:15 -0700 | [diff] [blame] | 46 |   void AddFile(const std::string& filename, const std::vector<Extent>& extents); | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 47 |  | 
| Alex Deymo | 2e9533b | 2015-06-26 20:57:06 -0700 | [diff] [blame] | 48 |   // Sets the PAYLOAD_MINOR_VERSION key stored by LoadSettings(). Use a negative | 
 | 49 |   // value to produce an error in LoadSettings(). | 
 | 50 |   void SetMinorVersion(int minor_version) { | 
 | 51 |     minor_version_ = minor_version; | 
 | 52 |   } | 
 | 53 |  | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 54 |  private: | 
 | 55 |   FakeFilesystem() = default; | 
 | 56 |  | 
 | 57 |   uint64_t block_size_; | 
 | 58 |   uint64_t block_count_; | 
| Alex Deymo | 2e9533b | 2015-06-26 20:57:06 -0700 | [diff] [blame] | 59 |   int minor_version_{-1}; | 
| Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame] | 60 |  | 
 | 61 |   std::vector<File> files_; | 
 | 62 |  | 
 | 63 |   DISALLOW_COPY_AND_ASSIGN(FakeFilesystem); | 
 | 64 | }; | 
 | 65 |  | 
 | 66 | }  // namespace chromeos_update_engine | 
 | 67 |  | 
 | 68 | #endif  // UPDATE_ENGINE_PAYLOAD_GENERATOR_FAKE_FILESYSTEM_H_ |