4
0

tree_print.rs 412 B

123456789101112131415161718
  1. use fdt::node::FdtNode;
  2. static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");
  3. fn main() {
  4. let fdt = fdt::Fdt::new(MY_FDT).unwrap();
  5. print_node(fdt.find_node("/").unwrap(), 0);
  6. }
  7. fn print_node(node: FdtNode<'_, '_>, n_spaces: usize) {
  8. (0..n_spaces).for_each(|_| print!(" "));
  9. println!("{}/", node.name);
  10. for child in node.children() {
  11. print_node(child, n_spaces + 4);
  12. }
  13. }