mapfile_filesystem.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // Copyright (C) 2016 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. //
  16. // A filesystem parser based on the Android .map files. When generating a
  17. // filesystem with the Android tools, either squashfs or ext4, a .map file can
  18. // be generated at the same time with the list of files and the 4K-blocks where
  19. // the data for those files is located in the filesystem. This class parses this
  20. // .map text file instead of parsing the structure of the actual filesystem
  21. // contents.
  22. #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_MAPFILE_FILESYSTEM_H_
  23. #define UPDATE_ENGINE_PAYLOAD_GENERATOR_MAPFILE_FILESYSTEM_H_
  24. #include "update_engine/payload_generator/filesystem_interface.h"
  25. #include <memory>
  26. #include <string>
  27. #include <vector>
  28. namespace chromeos_update_engine {
  29. class MapfileFilesystem : public FilesystemInterface {
  30. public:
  31. static std::unique_ptr<MapfileFilesystem> CreateFromFile(
  32. const std::string& filename, const std::string& mapfile_filename);
  33. virtual ~MapfileFilesystem() = default;
  34. // FilesystemInterface overrides.
  35. size_t GetBlockSize() const override;
  36. size_t GetBlockCount() const override;
  37. // All the generated FilesystemInterface::File are reported as regular files.
  38. // Files may overlap with other files in the same block.
  39. bool GetFiles(std::vector<File>* files) const override;
  40. bool LoadSettings(brillo::KeyValueStore* store) const override;
  41. private:
  42. MapfileFilesystem(const std::string& mapfile_filename, off_t num_blocks);
  43. // The file where the map filesystem is stored.
  44. std::string mapfile_filename_;
  45. // The number of blocks in the filesystem.
  46. off_t num_blocks_;
  47. DISALLOW_COPY_AND_ASSIGN(MapfileFilesystem);
  48. };
  49. } // namespace chromeos_update_engine
  50. #endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_MAPFILE_FILESYSTEM_H_