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

     1  // Copyright 2020 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  // acpicat cats ACPI tables from the kernel.
     6  // The default method is "files", commonly provided in Linux via /sys.
     7  // Other methods are available depending on the platform.
     8  // Further selection of which tables are used can be done with acpigrep.
     9  package main
    10  
    11  import (
    12  	"flag"
    13  	"log"
    14  	"os"
    15  
    16  	"github.com/u-root/u-root/pkg/acpi"
    17  )
    18  
    19  var (
    20  	source = flag.String("s", acpi.DefaultMethod, "source of the tables")
    21  	debug  = flag.Bool("d", false, "Enable debug prints")
    22  )
    23  
    24  func main() {
    25  	flag.Parse()
    26  	if *debug {
    27  		acpi.Debug = log.Printf
    28  	}
    29  	t, err := acpi.ReadTables(*source)
    30  	if err != nil {
    31  		log.Fatal(err)
    32  	}
    33  	if len(t) == 0 {
    34  		log.Fatalf("%s: no tables read", *source)
    35  	}
    36  	if err := acpi.WriteTables(os.Stdout, t[0], t[1:]...); err != nil {
    37  		log.Fatal(err)
    38  	}
    39  }