gopkg.in/hugelgupf/u-root.v9@v9.0.0-20180831063832-3f6f1057f09b/cmds/io/io_linux.go (about) 1 // Copyright 2012-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 // This file contains support functions for io for Linux. 6 package main 7 8 import ( 9 "encoding/binary" 10 "fmt" 11 "io" 12 ) 13 14 func in(f io.ReadSeeker, addr uint64, data interface{}) error { 15 _, err := f.Seek(int64(addr), 0) 16 if err != nil { 17 return fmt.Errorf("in: bad address %v: %v", addr, err) 18 } 19 return binary.Read(f, binary.LittleEndian, data) 20 } 21 22 func out(f io.WriteSeeker, addr uint64, data interface{}) error { 23 _, err := f.Seek(int64(addr), 0) 24 if err != nil { 25 return fmt.Errorf("out: bad address %v: %v", addr, err) 26 } 27 return binary.Write(f, binary.LittleEndian, data) 28 }