github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/exp/zbi/zbi.go (about)

     1  // Copyright 2022 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // zbi dumps the header of a Zircon boot image.
     6  //
     7  // Synopsis:
     8  //
     9  //	zbi FILE
    10  //
    11  // Description:
    12  //
    13  //	Debugging purposes.
    14  package main
    15  
    16  import (
    17  	"encoding/json"
    18  	"fmt"
    19  	"log"
    20  	"os"
    21  
    22  	"github.com/mvdan/u-root-coreutils/pkg/boot/zbi"
    23  )
    24  
    25  func main() {
    26  	if len(os.Args) != 2 {
    27  		log.Fatalf("usage: %s FILE", os.Args[0])
    28  	}
    29  
    30  	image, err := zbi.Load(os.Args[1])
    31  	if err != nil {
    32  		log.Fatal(err)
    33  	}
    34  
    35  	imageJSON, err := json.MarshalIndent(image, "", "  ")
    36  	if err != nil {
    37  		log.Fatalf(err.Error())
    38  	}
    39  	fmt.Printf("%s\n", string(imageJSON))
    40  }