github.com/andrewsun2898/u-root@v6.0.1-0.20200616011413-4b2895c1b815+incompatible/cmds/exp/zimage/zimage.go (about)

     1  // Copyright 2019 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  // zimage dumps the header of a zImage.
     6  //
     7  // Synopsis:
     8  //     zimage FILE
     9  //
    10  // Description:
    11  //     This is mainly for debugging purposes.
    12  package main
    13  
    14  import (
    15  	"fmt"
    16  	"log"
    17  	"os"
    18  
    19  	"github.com/u-root/u-root/pkg/zimage"
    20  )
    21  
    22  func main() {
    23  	if len(os.Args) != 2 {
    24  		log.Fatalf("usage: %s FILE", os.Args[0])
    25  	}
    26  
    27  	f, err := os.Open(os.Args[1])
    28  	if err != nil {
    29  		log.Fatal(err)
    30  	}
    31  
    32  	header, err := zimage.Parse(f)
    33  	if err != nil {
    34  		log.Fatal(err)
    35  	}
    36  	fmt.Printf("%#v\n", header)
    37  }