| 1 |
// Copyright 2017 The Go 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 syscall |
| 6 |
|
| 7 |
import ( |
| 8 |
"unsafe" |
| 9 |
) |
| 10 |
|
| 11 |
func (ts *StTimespec) Unix() (sec int64, nsec int64) { |
| 12 |
return int64(ts.Sec), int64(ts.Nsec) |
| 13 |
} |
| 14 |
|
| 15 |
func (ts *StTimespec) Nano() int64 { |
| 16 |
return int64(ts.Sec)*1e9 + int64(ts.Nsec) |
| 17 |
} |
| 18 |
|
| 19 |
func direntIno(buf []byte) (uint64, bool) { |
| 20 |
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino)) |
| 21 |
} |
| 22 |
|
| 23 |
func direntReclen(buf []byte) (uint64, bool) { |
| 24 |
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen)) |
| 25 |
} |
| 26 |
|
| 27 |
func direntNamlen(buf []byte) (uint64, bool) { |
| 28 |
reclen, ok := direntReclen(buf) |
| 29 |
if !ok { |
| 30 |
return 0, false |
| 31 |
} |
| 32 |
return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true |
| 33 |
} |