github.com/TrenchBoot/u-root@v6.0.1-0.20200623220532-550e36da3258+incompatible/pkg/ipmi/ipmi_linux.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  package ipmi
     6  
     7  import (
     8  	"fmt"
     9  	"os"
    10  )
    11  
    12  // Open a channel to an IPMI device /dev/ipmi{devnum}.
    13  func Open(devnum int) (*IPMI, error) {
    14  	d := fmt.Sprintf("/dev/ipmi%d", devnum)
    15  
    16  	f, err := os.OpenFile(d, os.O_RDWR, 0)
    17  	if err != nil {
    18  		return nil, err
    19  	}
    20  
    21  	return &IPMI{File: f}, nil
    22  }