forked from kata-containers/agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_arm64.go
42 lines (36 loc) · 1.16 KB
/
device_arm64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Copyright (c) 2019 ARM Limited
//
// SPDX-License-Identifier: Apache-2.0
//
package main
import (
"fmt"
"io/ioutil"
"path/filepath"
"strings"
)
const (
// From https://www.kernel.org/doc/Documentation/acpi/namespace.txt
// The Linux kernel's core ACPI subsystem creates struct acpi_device
// objects for ACPI namespace objects representing devices, power resources
// processors, thermal zones. Those objects are exported to user space via
// sysfs as directories in the subtree under /sys/devices/LNXSYSTM:00
acpiDevPath = "/devices/LNXSYSTM"
)
func createRootBusPath() (string, error) {
startRootBusPath := "/devices/platform"
endRootBusPath := "/pci0000:00"
sysStartRootBusPath := filepath.Join(sysfsDir, startRootBusPath)
files, err := ioutil.ReadDir(sysStartRootBusPath)
if err != nil {
return "", fmt.Errorf("Error reading %s: %s", sysStartRootBusPath, err)
}
// find out the directory end with ".pcie"
for _, file := range files {
if strings.HasSuffix(file.Name(), ".pcie") && file.IsDir() {
return filepath.Join(startRootBusPath, file.Name(), endRootBusPath), nil
}
}
return "", fmt.Errorf("no pcie bus found under %s", sysStartRootBusPath)
}