summary refs log tree commit diff
path: root/x86_64
diff options
context:
space:
mode:
authorGreg Hartman <ghartman@google.com>2019-04-24 02:03:29 +0000
committerchrome-bot <chrome-bot@chromium.org>2019-05-02 21:02:36 -0700
commit5dd8694d77f001f581a3f839621df55f357ca1eb (patch)
tree5355230d7cd13634c3a412e104939073d0cb5a6c /x86_64
parente23231ccffb149108bb9f80d0b467b24153fcbfa (diff)
downloadcrosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar.gz
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar.bz2
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar.lz
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar.xz
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.tar.zst
crosvm-5dd8694d77f001f581a3f839621df55f357ca1eb.zip
Add Android fstab support to aarch64, based on x86_64 version
Test: cargo test on x86_64 and aarch64, boot on aarch64
Change-Id: I29fb269abedaaca4168581aa7f92d413d51e9232
Reviewed-on: https://chromium-review.googlesource.com/1585279
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Greg Hartman <ghartman@google.com>
Diffstat (limited to 'x86_64')
-rw-r--r--x86_64/src/fdt.rs29
-rw-r--r--x86_64/src/lib.rs5
2 files changed, 6 insertions, 28 deletions
diff --git a/x86_64/src/fdt.rs b/x86_64/src/fdt.rs
index b072b9e..30d74c9 100644
--- a/x86_64/src/fdt.rs
+++ b/x86_64/src/fdt.rs
@@ -2,10 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-use arch::fdt::{begin_node, end_node, finish_fdt, property_string, start_fdt, Error};
+use arch::android::create_android_fdt;
+use arch::fdt::{begin_node, end_node, finish_fdt, start_fdt, Error};
 use std::fs::File;
-use std::io::BufRead;
-use std::io::BufReader;
 use std::mem;
 use sys_util::{GuestAddress, GuestMemory};
 
@@ -26,7 +25,7 @@ pub fn create_fdt(
     fdt_max_size: usize,
     guest_mem: &GuestMemory,
     fdt_load_offset: u64,
-    android_fstab: &mut File,
+    android_fstab: File,
 ) -> Result<usize, Error> {
     // Reserve space for the setup_data
     let fdt_data_size = fdt_max_size - mem::size_of::<setup_data>();
@@ -36,27 +35,7 @@ pub fn create_fdt(
 
     // The whole thing is put into one giant node with some top level properties
     begin_node(&mut fdt, "")?;
-    begin_node(&mut fdt, "firmware")?;
-    begin_node(&mut fdt, "android")?;
-    property_string(&mut fdt, "compatible", "android,firmware")?;
-    begin_node(&mut fdt, "fstab")?;
-    property_string(&mut fdt, "compatible", "android,fstab")?;
-    let file = BufReader::new(android_fstab);
-    for line in file.lines().filter_map(|l| l.ok()) {
-        let vec = line.split(" ").collect::<Vec<&str>>();
-        assert_eq!(vec.len(), 5);
-        let partition = &vec[1][1..];
-        begin_node(&mut fdt, partition)?;
-        property_string(&mut fdt, "compatible", &("android,".to_owned() + partition))?;
-        property_string(&mut fdt, "dev", vec[0])?;
-        property_string(&mut fdt, "type", vec[2])?;
-        property_string(&mut fdt, "mnt_flags", vec[3])?;
-        property_string(&mut fdt, "fsmgr_flags", vec[4])?;
-        end_node(&mut fdt)?;
-    }
-    end_node(&mut fdt)?;
-    end_node(&mut fdt)?;
-    end_node(&mut fdt)?;
+    create_android_fdt(&mut fdt, android_fstab)?;
     end_node(&mut fdt)?;
 
     // Allocate another buffer so we can format and then write fdt to guest
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index 684a60f..455e0ea 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -420,15 +420,14 @@ impl X8664arch {
         // data like the device tree blob and initrd will be loaded.
         let mut free_addr = kernel_end;
 
-        let setup_data = if let Some(fstab) = android_fstab {
-            let mut fstab = fstab;
+        let setup_data = if let Some(android_fstab) = android_fstab {
             let free_addr_aligned = (((free_addr + 64 - 1) / 64) * 64) + 64;
             let dtb_start = GuestAddress(free_addr_aligned);
             let dtb_size = fdt::create_fdt(
                 X86_64_FDT_MAX_SIZE as usize,
                 mem,
                 dtb_start.offset(),
-                &mut fstab,
+                android_fstab,
             )
             .map_err(Error::CreateFdt)?;
             free_addr = dtb_start.offset() + dtb_size as u64;