MCPcopy
hub / github.com/slimtoolkit/slim / NewKernelFeaturesWithProps

Function NewKernelFeaturesWithProps

pkg/system/kernel_linux.go:68–101  ·  view source on GitHub ↗
(location string)

Source from the content-addressed store, hash-verified

66}
67
68func NewKernelFeaturesWithProps(location string) (KernelFeatures, error) {
69 var kfeatures KernelFeatures
70
71 if location == "" {
72 bootConfigWithVersion := fmt.Sprintf("/boot/config-%s", defaultSysInfo.Machine)
73 kernelConfigLocations := []string{
74 "/proc/config.gz",
75 "/boot/config",
76 }
77
78 kernelConfigLocations = append(kernelConfigLocations, bootConfigWithVersion)
79
80 location = findKernelConfigs(kernelConfigLocations)
81 if location == "" {
82 kfeatures.Error = ErrNoConfigs.Error()
83 return kfeatures, ErrNoConfigs
84 }
85 } else {
86 if !fileExists(location) {
87 kfeatures.Error = os.ErrNotExist.Error()
88 return kfeatures, os.ErrNotExist
89 }
90 }
91
92 rawFeatures, err := readKernelFeatures(location)
93 if err != nil {
94 kfeatures.Error = err.Error()
95 return kfeatures, err
96 }
97
98 kfeatures.Raw = rawFeatures
99
100 return kfeatures, nil
101}
102
103var DefaultKernelFeatures, _ = NewKernelFeatures()
104

Callers 1

NewKernelFeaturesFunction · 0.85

Calls 4

findKernelConfigsFunction · 0.85
fileExistsFunction · 0.85
readKernelFeaturesFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected