refactor: Decompose tell syscall

This commit is contained in:
Felicitas Pojtinger
2021-11-19 00:16:42 +01:00
parent 621cc0b055
commit f8ba6ce6c7

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
}