github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/pkg/cmdline/cmdline_linux.go (about) 1 // Copyright 2018 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package cmdline 6 7 import ( 8 "os" 9 ) 10 11 const cmdLinePath = "/proc/cmdline" 12 13 var procCmdLine *CmdLine 14 15 func cmdLine(n string) *CmdLine { 16 procCmdLine = &CmdLine{AsMap: map[string]string{}} 17 r, err := os.Open(n) 18 if err != nil { 19 procCmdLine.Err = err 20 return procCmdLine 21 } 22 23 defer r.Close() 24 25 procCmdLine = parse(r) 26 return procCmdLine 27 } 28 29 func getCmdLine() *CmdLine { 30 return cmdLine(cmdLinePath) 31 }