blob: 61f755c4b545e17737d9cca990abea6297094519 [file] [log] [blame]
Sen Jiang0a582fb2018-06-26 19:27:21 -07001//
2// Copyright (C) 2018 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
17#ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_BOOT_IMG_FILESYSTEM_H_
18#define UPDATE_ENGINE_PAYLOAD_GENERATOR_BOOT_IMG_FILESYSTEM_H_
19
20#include "update_engine/payload_generator/filesystem_interface.h"
21
22#include <memory>
23#include <string>
24#include <vector>
25
26namespace chromeos_update_engine {
27
28class BootImgFilesystem : public FilesystemInterface {
29 public:
30 // Creates an BootImgFilesystem from an Android boot.img file.
31 static std::unique_ptr<BootImgFilesystem> CreateFromFile(
32 const std::string& filename);
33 ~BootImgFilesystem() override = default;
34
35 // FilesystemInterface overrides.
36 size_t GetBlockSize() const override;
37 size_t GetBlockCount() const override;
38
39 // GetFiles will return one FilesystemInterface::File for kernel and one for
40 // ramdisk.
41 bool GetFiles(std::vector<File>* files) const override;
42
43 bool LoadSettings(brillo::KeyValueStore* store) const override;
44
45 private:
46 friend class BootImgFilesystemTest;
47
48 BootImgFilesystem() = default;
49
50 File GetFile(const std::string& name, uint64_t offset, uint64_t size) const;
51
52 // The boot.img file path.
53 std::string filename_;
54
Tianjie37ae8562020-03-25 15:16:01 -070055 uint32_t kernel_size_; /* size in bytes */
56 uint32_t ramdisk_size_; /* size in bytes */
57 uint32_t page_size_; /* flash page size we assume */
Sen Jiang0a582fb2018-06-26 19:27:21 -070058
59 DISALLOW_COPY_AND_ASSIGN(BootImgFilesystem);
60};
61
62} // namespace chromeos_update_engine
63
64#endif // UPDATE_ENGINE_PAYLOAD_GENERATOR_BOOT_IMG_FILESYSTEM_H_