github.com/ratrocket/u-root@v0.0.0-20180201221235-1cf9f48ee2cf/pkg/kexec/kexec_linux.go (about) 1 // Copyright 2015-2017 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 kexec 6 7 import ( 8 "fmt" 9 "io/ioutil" 10 "strings" 11 "syscall" 12 ) 13 14 // Reboot executes a kernel previously loaded with FileInit. 15 func Reboot() error { 16 if err := syscall.Reboot(syscall.LINUX_REBOOT_CMD_KEXEC); err != nil { 17 return fmt.Errorf("sys_reboot(..., kexec) = %v", err) 18 } 19 return nil 20 } 21 22 func CurrentKernelCmdline() (string, error) { 23 procCmdline, err := ioutil.ReadFile("/proc/cmdline") 24 if err != nil { 25 return "", err 26 } 27 return strings.TrimRight(string(procCmdline), "\n"), nil 28 }