github.com/mem/u-root@v2.0.1-0.20181004165302-9b18b4636a33+incompatible/integration/testdata/kexec/uinit/kexec.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 main 6 7 import ( 8 "fmt" 9 "log" 10 11 "github.com/u-root/u-root/pkg/cmdline" 12 "github.com/u-root/u-root/pkg/sh" 13 ) 14 15 // Mount a vfat volume and kexec the kernel within. 16 func main() { 17 sh.RunOrDie("mkdir", "/testdata") 18 sh.RunOrDie("mount", "-r", "-t", "vfat", "/dev/sda1", "/testdata") 19 20 // Get and increment the counter. 21 kExecCounter, ok := cmdline.Flag("kexeccounter") 22 if !ok { 23 kExecCounter = "0" 24 } 25 fmt.Printf("KEXECCOUNTER=%s\n", kExecCounter) 26 27 if kExecCounter == "0" { 28 cmdLine := cmdline.FullCmdLine() + " kexeccounter=1" 29 log.Print("cmdline: ", cmdLine) 30 sh.RunOrDie("kexec", 31 "-i", "/testdata/initramfs.cpio", 32 "-c", cmdLine, 33 "/testdata/bzImage") 34 } 35 }