-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmount_linux.go
More file actions
39 lines (30 loc) · 1.04 KB
/
Copy pathmount_linux.go
File metadata and controls
39 lines (30 loc) · 1.04 KB
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
//go:build linux
package mount
import (
"path/filepath"
"golang.org/x/sys/unix"
)
const (
pciDevicesPath = "/sys/bus/pci/devices"
kubeletDir = "/var/lib/kubelet"
)
func newDeviceStats(statfs *unix.Statfs_t) *DeviceStats {
return &DeviceStats{
Block: false,
AvailableBytes: int64(statfs.Bavail) * statfs.Bsize,
TotalBytes: int64(statfs.Blocks) * statfs.Bsize,
UsedBytes: (int64(statfs.Blocks) - int64(statfs.Bfree)) * statfs.Bsize,
AvailableInodes: int64(statfs.Ffree),
TotalInodes: int64(statfs.Files),
UsedInodes: int64(statfs.Files) - int64(statfs.Ffree),
}
}
// CountFreePCIeSlots returns the number of PCIe root ports that are not occupied.
func CountFreePCIeSlots() (int64, error) {
return countFreePCIeSlotsAt(pciDevicesPath)
}
// CountLocalCSIVolumes counts staged CSI volumes for the given driver.
func CountLocalCSIVolumes(driverName string) (int64, error) {
driverPluginDir := filepath.Join(kubeletDir, "plugins", "kubernetes.io", "csi", driverName)
return countLocalCSIVolumesAt(driverPluginDir)
}