initrd/params.go

24 lines
428 B
Go
Raw Normal View History

2019-02-11 05:05:43 +00:00
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
}