Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from syscall.Getdents to unix.Getdents #202

Merged
merged 1 commit into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions fuse/test/loopback_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"testing"
"time"

"golang.org/x/sys/unix"

"github.com/hanwen/go-fuse/fuse"
)

Expand Down Expand Up @@ -143,7 +145,7 @@ func TestFallocate(t *testing.T) {
}
}

// Check that "." and ".." exists. syscall.Getdents is linux specific.
// Check that "." and ".." exists. unix.Getdents is linux specific.
func TestSpecialEntries(t *testing.T) {
tc := NewTestCase(t)
defer tc.Cleanup()
Expand All @@ -154,7 +156,7 @@ func TestSpecialEntries(t *testing.T) {
}
defer d.Close()
buf := make([]byte, 100)
n, err := syscall.Getdents(int(d.Fd()), buf)
n, err := unix.Getdents(int(d.Fd()), buf)
if n == 0 {
t.Errorf("directory is empty, entries '.' and '..' are missing")
}
Expand All @@ -180,7 +182,7 @@ func TestReaddirInodes(t *testing.T) {
buf := make([]byte, 100)
// readdir(3) use getdents64(2) internally which returns linux_dirent64
// structures. We don't have readdir(3) so we call getdents64(2) directly.
n, err := syscall.Getdents(int(d.Fd()), buf)
n, err := unix.Getdents(int(d.Fd()), buf)
if n == 0 {
t.Error("empty directory - we need at least one file")
}
Expand Down
4 changes: 3 additions & 1 deletion fuse/test/xfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"syscall"
"testing"
"unsafe"

"golang.org/x/sys/unix"
)

func clen(n []byte) int {
Expand All @@ -34,7 +36,7 @@ type CDirent struct {
func parseDirents(buf []byte) []CDirent {
var result []CDirent
for len(buf) > 0 {
de := *(*syscall.Dirent)(unsafe.Pointer(&buf[0]))
de := *(*unix.Dirent)(unsafe.Pointer(&buf[0]))
buf = buf[de.Reclen:]
bytes := (*[10000]byte)(unsafe.Pointer(&de.Name[0]))
var name = string(bytes[0:clen(bytes[:])])
Expand Down