Fix unit tests
[govpp.git] / vendor / golang.org / x / sys / unix / syscall_netbsd.go
index c4e945c..01f6a48 100644 (file)
@@ -93,32 +93,16 @@ func nametomib(name string) (mib []_C_int, err error) {
        return mib, nil
 }
 
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
-       origlen := len(buf)
-       for max != 0 && len(buf) > 0 {
-               dirent := (*Dirent)(unsafe.Pointer(&buf[0]))
-               if dirent.Reclen == 0 {
-                       buf = nil
-                       break
-               }
-               buf = buf[dirent.Reclen:]
-               if dirent.Fileno == 0 { // File absent in directory.
-                       continue
-               }
-               bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
-               var name = string(bytes[0:dirent.Namlen])
-               if name == "." || name == ".." { // Useless names
-                       continue
-               }
-               max--
-               count++
-               names = append(names, name)
-       }
-       return origlen - len(buf), count, names
+func direntIno(buf []byte) (uint64, bool) {
+       return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
+}
+
+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))
 }
 
 //sysnb pipe() (fd1 int, fd2 int, err error)