mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
unix: don't use syscall.ParseDirent
Implement ParseDirent in x/sys/unix instead of calling syscall.ParseDirent. The latter uses offsets into syscall.Dirent which might not be matching unix.Dirent depending on Go version. This is e.g. the case with of FreeBSD whose Dirent structure was updated for Go 1.12. This fixes TestDirent and TestGetdirentries on freebsd with Go 1.11 Reverts CL 88475 Change-Id: I04318f59c6fbf148c75ce3667255a0c0428288e2 Reviewed-on: https://go-review.googlesource.com/c/sys/+/183897 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
This commit is contained in:
committed by
Tobias Klauser
parent
c5567b49c5
commit
e07cf5db27
@@ -77,6 +77,18 @@ func nametomib(name string) (mib []_C_int, err error) {
|
||||
return buf[0 : n/siz], nil
|
||||
}
|
||||
|
||||
func direntIno(buf []byte) (uint64, bool) {
|
||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
|
||||
}
|
||||
|
||||
func direntReclen(buf []byte) (uint64, bool) {
|
||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
|
||||
}
|
||||
|
||||
func direntNamlen(buf []byte) (uint64, bool) {
|
||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
||||
}
|
||||
|
||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
||||
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
||||
|
||||
Reference in New Issue
Block a user