mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-19 19:41:16 +02:00
31 lines
772 B
Go
31 lines
772 B
Go
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package kernel
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"strings"
|
|
)
|
|
|
|
// ParseProcCmdline parses /proc/cmdline and returns a map reprentation of the
|
|
// kernel parameters.
|
|
func ParseProcCmdline() (cmdline map[string]string, err error) {
|
|
cmdline = map[string]string{}
|
|
cmdlineBytes, err := ioutil.ReadFile("/proc/cmdline")
|
|
if err != nil {
|
|
return
|
|
}
|
|
line := strings.TrimSuffix(string(cmdlineBytes), "\n")
|
|
arguments := strings.Split(line, " ")
|
|
for _, a := range arguments {
|
|
kv := strings.Split(a, "=")
|
|
if len(kv) == 2 {
|
|
cmdline[kv[0]] = kv[1]
|
|
}
|
|
}
|
|
|
|
return cmdline, err
|
|
}
|