refactor: Decompose tell syscall

This commit is contained in:
Felix Pojtinger
2021-11-19 00:16:42 +01:00
parent 75f59e3b45
commit 08fde43223

View File

@@ -29,14 +29,24 @@ func main() {
}
defer f.Close()
pos := &Position{}
currentRecord, err := getCurrentRecordFromTape(f)
if err != nil {
panic(err)
}
syscall.Syscall(
fmt.Println(currentRecord)
}
func getCurrentRecordFromTape(f *os.File) (int64, error) {
pos := &Position{}
if _, _, err := syscall.Syscall(
syscall.SYS_IOCTL,
f.Fd(),
MTIOCPOS,
uintptr(unsafe.Pointer(pos)),
)
); err != 0 {
return 0, err
}
fmt.Println(pos.BlkNo)
return pos.BlkNo, nil
}