MCPcopy
hub / github.com/jaypipes/ghw / New

Function New

pkg/linuxpath/path_linux.go:81–102  ·  view source on GitHub ↗

New returns a new Paths struct containing filepath fields relative to the supplied Context

(ctx context.Context)

Source from the content-addressed store, hash-verified

79// New returns a new Paths struct containing filepath fields relative to the
80// supplied Context
81func New(ctx context.Context) *Paths {
82 roots := PathRootsFromContext(ctx)
83 chroot := config.Chroot(ctx)
84 return &Paths{
85 SysRoot: filepath.Join(chroot, roots.Sys),
86 VarLog: filepath.Join(chroot, roots.Var, "log"),
87 ProcMeminfo: filepath.Join(chroot, roots.Proc, "meminfo"),
88 ProcCpuinfo: filepath.Join(chroot, roots.Proc, "cpuinfo"),
89 ProcMounts: filepath.Join(chroot, roots.Proc, "self", "mounts"),
90 SysKernelMMHugepages: filepath.Join(chroot, roots.Sys, "kernel", "mm", "hugepages"),
91 SysBlock: filepath.Join(chroot, roots.Sys, "block"),
92 SysDevicesSystemNode: filepath.Join(chroot, roots.Sys, "devices", "system", "node"),
93 SysDevicesSystemMemory: filepath.Join(chroot, roots.Sys, "devices", "system", "memory"),
94 SysDevicesSystemCPU: filepath.Join(chroot, roots.Sys, "devices", "system", "cpu"),
95 SysBusPciDevices: filepath.Join(chroot, roots.Sys, "bus", "pci", "devices"),
96 SysBusUsbDevices: filepath.Join(chroot, roots.Sys, "bus", "usb", "devices"),
97 SysClassDRM: filepath.Join(chroot, roots.Sys, "class", "drm"),
98 SysClassDMI: filepath.Join(chroot, roots.Sys, "class", "dmi"),
99 SysClassNet: filepath.Join(chroot, roots.Sys, "class", "net"),
100 RunUdevData: filepath.Join(chroot, roots.Run, "udev", "data"),
101 }
102}
103
104func (p *Paths) NodeCPU(nodeID int, lpID int) string {
105 return filepath.Join(

Callers 15

TestPathRootFunction · 0.92
TestPathSpecificRootsFunction · 0.92
loadMethod · 0.92
gpuFillNUMANodesFunction · 0.92
getDeviceNUMANodeFunction · 0.92
getDevicesMethod · 0.92
CachesForNodeFunction · 0.92
loadMethod · 0.92
topologyNodesFunction · 0.92
processorsGetFunction · 0.92

Calls 2

ChrootFunction · 0.92
PathRootsFromContextFunction · 0.85

Tested by 8

TestPathRootFunction · 0.74
TestPathSpecificRootsFunction · 0.74
TestDiskPartLabelFunction · 0.74
TestDiskFSLabelFunction · 0.74
TestDiskTypeUdevFunction · 0.74
TestDiskPartUUIDFunction · 0.74