Revert "Revert "Match create_composite_disk to crosvm updates""
This reverts commit e573e22a5b110a8d74e075e9e6193dab8c354117.
Reason for revert: Needed to land https://android-review.googlesource.com/c/platform/external/crosvm/+/2037643
Change-Id: I94ed2c8cb10128f2adaddad97750593dbab47905
diff --git a/virtualizationservice/src/composite.rs b/virtualizationservice/src/composite.rs
index cb814f3..aee84cd 100644
--- a/virtualizationservice/src/composite.rs
+++ b/virtualizationservice/src/composite.rs
@@ -94,8 +94,8 @@
.as_ref()
.try_clone()
.context("Failed to clone partition image file descriptor")?;
- let size = get_partition_size(&file)?;
let path = fd_path_for_file(&file);
+ let size = get_partition_size(&file, &path)?;
files.push(file);
Ok(PartitionInfo {
@@ -119,9 +119,9 @@
/// Find the size of the partition image in the given file by parsing the header.
///
/// This will work for raw, QCOW2, composite and Android sparse images.
-fn get_partition_size(partition: &File) -> Result<u64, Error> {
+fn get_partition_size(partition: &File, path: &Path) -> Result<u64, Error> {
// TODO: Use `context` once disk::Error implements std::error::Error.
- Ok(create_disk_file(partition.try_clone()?, MAX_NESTING_DEPTH)
+ Ok(create_disk_file(partition.try_clone()?, MAX_NESTING_DEPTH, path)
.map_err(|e| anyhow!("Failed to open partition image: {}", e))?
.get_len()?)
}