diff options
Diffstat (limited to 'cmd/earlyinit/hsu.go')
| -rw-r--r-- | cmd/earlyinit/hsu.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/earlyinit/hsu.go b/cmd/earlyinit/hsu.go new file mode 100644 index 00000000..ea25c1a9 --- /dev/null +++ b/cmd/earlyinit/hsu.go @@ -0,0 +1,32 @@ +package main + +import ( + "os" + "strconv" +) + +// updateHsu replaces the hsurc file. +func updateHsu(pairs [][2]uint32) error { + w, err := os.OpenFile( + "/misc/hsurc", + os.O_CREATE|os.O_TRUNC|os.O_WRONLY, + 0400, + ) + if err != nil { + return err + } + + buf := make([]byte, 0, os.Getpagesize()) + for _, pair := range pairs { + buf = buf[:0] + buf = strconv.AppendUint(buf, uint64(pair[0]), 10) + buf = append(buf, ' ') + buf = strconv.AppendUint(buf, uint64(pair[1]), 10) + buf = append(buf, '\n') + if _, err = w.Write(buf); err != nil { + _ = w.Close() + return err + } + } + return w.Close() +} |
