|
|
@@ -120,9 +120,30 @@ func Pipe(p []int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//sys getdents(fd int, buf []byte) (n int, err error)
|
|
|
+//sys Getdents(fd int, buf []byte) (n int, err error)
|
|
|
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
|
|
- return getdents(fd, buf)
|
|
|
+ n, err = Getdents(fd, buf)
|
|
|
+ if err != nil || basep == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var off int64
|
|
|
+ off, err = Seek(fd, 0, 1 /* SEEK_CUR */)
|
|
|
+ if err != nil {
|
|
|
+ *basep = ^uintptr(0)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ *basep = uintptr(off)
|
|
|
+ if unsafe.Sizeof(*basep) == 8 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if off>>4 != 0 {
|
|
|
+ // We can't stuff the offset back into a uintptr, so any
|
|
|
+ // future calls would be suspect. Generate an error.
|
|
|
+ // EIO is allowed by getdirentries.
|
|
|
+ err = EIO
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
const ImplementsGetwd = true
|