Rename payload metadata partition
/dev/block/by-name/metadata is used by others as well. Renamed it as payload-metadata. Bug: 191097666 Test: MicrodroidHostTestCases Change-Id: I873ee2acbe38772e59c96b3904023ac0d1573621
This commit is contained in:
parent
9900f3d733
commit
14e5a8e3bc
|
@ -7,7 +7,7 @@ mounts/activates APK/APEXes and executes a binary within the APK.
|
|||
|
||||
Payload disk has 1 + N(number of APEX/APK payloads) partitions.
|
||||
|
||||
The first partition is a "metadata" partition which describes other partitions.
|
||||
The first partition is a "payload-metadata" partition which describes other partitions.
|
||||
And APEXes and an APK are following as separate partitions.
|
||||
|
||||
For now, the order of partitions are important.
|
||||
|
|
|
@ -10,6 +10,7 @@ rust_library {
|
|||
prefer_rlib: true,
|
||||
edition: "2018",
|
||||
rustlibs: [
|
||||
"libanyhow",
|
||||
"libmicrodroid_metadata_proto_rust",
|
||||
"libprotobuf",
|
||||
],
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
//! 4 bytes : size(N) in big endian
|
||||
//! N bytes : protobuf message for Metadata
|
||||
|
||||
use anyhow::Result;
|
||||
use protobuf::Message;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
|
||||
pub use microdroid_metadata::metadata::{ApexPayload, ApkPayload, Metadata};
|
||||
|
||||
/// Reads a metadata from a reader
|
||||
pub fn read_metadata<T: Read>(mut r: T) -> io::Result<Metadata> {
|
||||
pub fn read_metadata<T: Read>(mut r: T) -> Result<Metadata> {
|
||||
let mut buf = [0u8; 4];
|
||||
r.read_exact(&mut buf)?;
|
||||
let size = i32::from_be_bytes(buf);
|
||||
|
@ -34,9 +34,10 @@ pub fn read_metadata<T: Read>(mut r: T) -> io::Result<Metadata> {
|
|||
}
|
||||
|
||||
/// Writes a metadata to a writer
|
||||
pub fn write_metadata<T: Write>(metadata: &Metadata, mut w: T) -> io::Result<()> {
|
||||
pub fn write_metadata<T: Write>(metadata: &Metadata, mut w: T) -> Result<()> {
|
||||
let mut buf = Vec::new();
|
||||
metadata.write_to_writer(&mut buf)?;
|
||||
w.write_all(&(buf.len() as i32).to_be_bytes())?;
|
||||
w.write_all(&buf)
|
||||
w.write_all(&buf)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ Result<void> MakePayload(const Config& config, const std::string& metadata_file,
|
|||
|
||||
// put metadata at the first partition
|
||||
partitions.push_back(MultipleImagePartition{
|
||||
.label = "metadata",
|
||||
.label = "payload-metadata",
|
||||
.image_file_paths = {metadata_file},
|
||||
.type = kLinuxFilesystem,
|
||||
.read_only = true,
|
||||
|
|
|
@ -6,7 +6,7 @@ type apkdmverity_exec, exec_type, file_type, system_file_type;
|
|||
# allow domain transition from init
|
||||
init_daemon_domain(apkdmverity)
|
||||
|
||||
# apkdmverity accesses /dev/block/by-name/metadata which points to
|
||||
# apkdmverity accesses "payload metadata disk" which points to
|
||||
# a /dev/vd* block device file.
|
||||
allow apkdmverity block_device:dir r_dir_perms;
|
||||
allow apkdmverity block_device:lnk_file r_file_perms;
|
||||
|
|
|
@ -6,8 +6,7 @@ type microdroid_manager_exec, exec_type, file_type, system_file_type;
|
|||
# allow domain transition from init
|
||||
init_daemon_domain(microdroid_manager)
|
||||
|
||||
# microdroid_manager accesses /dev/block/by-name/metadata which points to
|
||||
# a /dev/vd* block device file.
|
||||
# microdroid_manager accesses a virtual disk block device to read VM payload
|
||||
allow microdroid_manager block_device:dir r_dir_perms;
|
||||
allow microdroid_manager block_device:lnk_file r_file_perms;
|
||||
allow microdroid_manager vd_device:blk_file r_file_perms;
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Payload metadata from /dev/block/by-name/metadata
|
||||
//! Payload metadata from /dev/block/by-name/payload-metadata
|
||||
|
||||
use anyhow::Result;
|
||||
use log::info;
|
||||
use microdroid_metadata::{read_metadata, Metadata};
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
|
||||
const METADATA_PATH: &str = "/dev/block/by-name/metadata";
|
||||
const PAYLOAD_METADATA_PATH: &str = "/dev/block/by-name/payload-metadata";
|
||||
|
||||
/// loads payload metadata from /dev/block/by-name/metadata
|
||||
pub fn load() -> io::Result<Metadata> {
|
||||
/// loads payload metadata from /dev/block/by-name/paylaod-metadata
|
||||
pub fn load() -> Result<Metadata> {
|
||||
info!("loading payload metadata...");
|
||||
read_metadata(File::open(METADATA_PATH)?)
|
||||
read_metadata(File::open(PAYLOAD_METADATA_PATH)?)
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ pub fn make_payload_disk(
|
|||
|
||||
// put metadata at the first partition
|
||||
let mut partitions = vec![Partition {
|
||||
label: "metadata".to_owned(),
|
||||
label: "payload-metadata".to_owned(),
|
||||
paths: vec![metadata_path],
|
||||
writable: false,
|
||||
}];
|
||||
|
|
Loading…
Reference in New Issue