inits/cmd/dkl-initrd-init/params.go
2018-07-06 19:07:37 +11:00

24 lines
428 B
Go

package main
import (
"io/ioutil"
"strings"
)
func param(name, defaultValue string) (value string) {
ba, err := ioutil.ReadFile("/proc/cmdline")
if err != nil {
fatal("could not read /proc/cmdline: ", err)
}
prefix := "direktil." + name + "="
for _, part := range strings.Split(string(ba), " ") {
if strings.HasPrefix(part, prefix) {
return strings.TrimSpace(part[len(prefix):])
}
}
return defaultValue
}