Debian Codegraph @

README.md

raw symbols SCIP
1 go-smbios [![Build Status](https://travis-ci.org/digitalocean/go-smbios.svg?branch=master)](https://travis-ci.org/digitalocean/go-smbios) [![GoDoc](https://godoc.org/github.com/digitalocean/go-smbios/smbios?status.svg)](https://godoc.org/github.com/digitalocean/go-smbios/smbios) [![Go Report Card](https://goreportcard.com/badge/github.com/digitalocean/go-smbios)](https://goreportcard.com/report/github.com/digitalocean/go-smbios)
2 =========
3
4 Package `smbios` provides detection and access to System Management BIOS (SMBIOS)
5 and Desktop Management Interface (DMI) data and structures. Apache 2.0 Licensed.
6
7 Introduction
8 ------------
9
10 [SMBIOS](https://en.wikipedia.org/wiki/System_Management_BIOS) is a standard
11 mechanism for fetching BIOS and hardware information from within an operating
12 system. It shares some similarities with the older DMI standard, and the two are
13 often confused.
14
15 To install this package, run:
16
17 ```
18 $ go get github.com/digitalocean/go-smbios/smbios
19 ```
20
21 This package is based on the [SMBIOS 3.1.1 specification](https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf),
22 but should work with SMBIOS 2.0 and above.
23
24 In general, it's up to hardware manufacturers to properly populate SMBIOS data,
25 and many structures may not be populated correctly or at all; especially on
26 consumer hardware.
27
28 The `smbios.Structure` types created by this package can be decoded using the
29 structure information in the SMBIOS specification. In the future, some common
30 structures may be parsed and readily available by using this package.
31
32 Supported operating systems and their SMBIOS retrieval mechanisms include:
33
34 - DragonFlyBSD (/dev/mem)
35 - FreeBSD (/dev/mem)
36 - Linux (sysfs and /dev/mem)
37 - NetBSD (/dev/mem)
38 - OpenBSD (/dev/mem)
39 - Solaris (/dev/mem)
40 - Windows (GetSystemFirmwareTable)
41
42 At this time, macOS is not supported, as it does not expose
43 SMBIOS information in the same way as the supported operating systems. Pull
44 requests are welcome to add support for additional operating systems.
45
46 Example
47 -------
48
49 See `cmd/lssmbios` for a runnable example. Note that retrieving SMBIOS
50 information is a privileged operation. On Linux, you may invoke the binary
51 as root directly, or apply the `CAP_DAC_OVERRIDE` capability to enable reading
52 the information without superuser access.
53
54 Here's the gist of it:
55
56 ```go
57 // Find SMBIOS data in operating system-specific location.
58 rc, ep, err := smbios.Stream()
59 if err != nil {
60 log.Fatalf("failed to open stream: %v", err)
61 }
62 // Be sure to close the stream!
63 defer rc.Close()
64
65 // Decode SMBIOS structures from the stream.
66 d := smbios.NewDecoder(rc)
67 ss, err := d.Decode()
68 if err != nil {
69 log.Fatalf("failed to decode structures: %v", err)
70 }
71
72 // Determine SMBIOS version and table location from entry point.
73 major, minor, rev := ep.Version()
74 addr, size := ep.Table()
75
76 fmt.Printf("SMBIOS %d.%d.%d - table: address: %#x, size: %d\n",
77 major, minor, rev, addr, size)
78
79 for _, s := range ss {
80 fmt.Println(s)
81 }
82 ```