Jooyung Han | 7457348 | 2021-06-08 17:10:21 +0900 | [diff] [blame] | 1 | // Copyright 2021, The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | //! Payload metadata from /dev/block/by-name/metadata |
| 16 | |
| 17 | use log::info; |
Jooyung Han | f1e0086 | 2021-06-25 12:02:33 +0900 | [diff] [blame^] | 18 | use microdroid_metadata::{read_metadata, Metadata}; |
Jooyung Han | 7457348 | 2021-06-08 17:10:21 +0900 | [diff] [blame] | 19 | use std::fs::File; |
| 20 | use std::io; |
Jooyung Han | 7457348 | 2021-06-08 17:10:21 +0900 | [diff] [blame] | 21 | |
| 22 | const METADATA_PATH: &str = "/dev/block/by-name/metadata"; |
| 23 | |
| 24 | /// loads payload metadata from /dev/block/by-name/metadata |
| 25 | pub fn load() -> io::Result<Metadata> { |
| 26 | info!("loading payload metadata..."); |
Jooyung Han | f1e0086 | 2021-06-25 12:02:33 +0900 | [diff] [blame^] | 27 | read_metadata(File::open(METADATA_PATH)?) |
Jooyung Han | 7457348 | 2021-06-08 17:10:21 +0900 | [diff] [blame] | 28 | } |