mirror of
https://github.com/containers/podman.git
synced 2025-11-14 01:57:58 +08:00
vendor: bump buildah to v1.26.1-0.20220524184833-5500333c2e06
Bump buildah to v1.26.1-0.20220524184833-5500333c2e06 Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
84
vendor/github.com/containers/storage/pkg/system/meminfo_freebsd.go
generated
vendored
Normal file
84
vendor/github.com/containers/storage/pkg/system/meminfo_freebsd.go
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
//go:build freebsd && cgo
|
||||
// +build freebsd,cgo
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// #include <unistd.h>
|
||||
// #include <sys/vmmeter.h>
|
||||
// #include <sys/sysctl.h>
|
||||
// #include <vm/vm_param.h>
|
||||
import "C"
|
||||
|
||||
func getMemInfo() (int64, int64, error) {
|
||||
data, err := unix.SysctlRaw("vm.vmtotal")
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("Can't get kernel info: %v", err)
|
||||
}
|
||||
if len(data) != C.sizeof_struct_vmtotal {
|
||||
return -1, -1, fmt.Errorf("unexpected vmtotal size %d", len(data))
|
||||
}
|
||||
|
||||
total := (*C.struct_vmtotal)(unsafe.Pointer(&data[0]))
|
||||
|
||||
pagesize := int64(C.sysconf(C._SC_PAGESIZE))
|
||||
npages := int64(C.sysconf(C._SC_PHYS_PAGES))
|
||||
return pagesize * npages, pagesize * int64(total.t_free), nil
|
||||
}
|
||||
|
||||
func getSwapInfo() (int64, int64, error) {
|
||||
var (
|
||||
total int64 = 0
|
||||
used int64 = 0
|
||||
)
|
||||
swapCount, err := unix.SysctlUint32("vm.nswapdev")
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("error reading vm.nswapdev: %v", err)
|
||||
}
|
||||
for i := 0; i < int(swapCount); i++ {
|
||||
data, err := unix.SysctlRaw("vm.swap_info", i)
|
||||
if err != nil {
|
||||
return -1, -1, fmt.Errorf("error reading vm.swap_info.%d: %v", i, err)
|
||||
}
|
||||
if len(data) != C.sizeof_struct_xswdev {
|
||||
return -1, -1, fmt.Errorf("unexpected swap_info size %d", len(data))
|
||||
}
|
||||
xsw := (*C.struct_xswdev)(unsafe.Pointer(&data[0]))
|
||||
total += int64(xsw.xsw_nblks)
|
||||
used += int64(xsw.xsw_used)
|
||||
}
|
||||
pagesize := int64(C.sysconf(C._SC_PAGESIZE))
|
||||
return pagesize * total, pagesize * (total - used), nil
|
||||
}
|
||||
|
||||
// ReadMemInfo retrieves memory statistics of the host system and returns a
|
||||
// MemInfo type.
|
||||
func ReadMemInfo() (*MemInfo, error) {
|
||||
MemTotal, MemFree, err := getMemInfo()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting memory totals %v\n", err)
|
||||
}
|
||||
SwapTotal, SwapFree, err := getSwapInfo()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting swap totals %v\n", err)
|
||||
}
|
||||
|
||||
if MemTotal < 0 || MemFree < 0 || SwapTotal < 0 || SwapFree < 0 {
|
||||
return nil, fmt.Errorf("error getting system memory info %v\n", err)
|
||||
}
|
||||
|
||||
meminfo := &MemInfo{}
|
||||
// Total memory is total physical memory less than memory locked by kernel
|
||||
meminfo.MemTotal = MemTotal
|
||||
meminfo.MemFree = MemFree
|
||||
meminfo.SwapTotal = SwapTotal
|
||||
meminfo.SwapFree = SwapFree
|
||||
|
||||
return meminfo, nil
|
||||
}
|
||||
3
vendor/github.com/containers/storage/pkg/system/meminfo_unsupported.go
generated
vendored
3
vendor/github.com/containers/storage/pkg/system/meminfo_unsupported.go
generated
vendored
@@ -1,4 +1,5 @@
|
||||
// +build !linux,!windows,!solaris
|
||||
//go:build !linux && !windows && !solaris && !freebsd
|
||||
// +build !linux,!windows,!solaris,!freebsd
|
||||
|
||||
package system
|
||||
|
||||
|
||||
Reference in New Issue
Block a user