diff --git a/nfs/rpc/client.go b/nfs/rpc/client.go index c70e5e1..2288125 100644 --- a/nfs/rpc/client.go +++ b/nfs/rpc/client.go @@ -10,10 +10,8 @@ import ( "io" "math/rand" "net" - "os" "sync" "sync/atomic" - "syscall" "time" "github.com/willscott/go-nfs-client/nfs/util" @@ -58,15 +56,6 @@ type Client struct { replies map[uint32]chan io.ReadSeeker } -func isAddrInUse(err error) bool { - if er, ok := (err.(*net.OpError)); ok { - if syser, ok := er.Err.(*os.SyscallError); ok { - return syser.Err == syscall.EADDRINUSE - } - } - return false -} - func DialTCP(network string, addr string, privileged bool) (*Client, error) { c := &Client{ network: network, diff --git a/nfs/rpc/client_plan9.go b/nfs/rpc/client_plan9.go new file mode 100644 index 0000000..1f86134 --- /dev/null +++ b/nfs/rpc/client_plan9.go @@ -0,0 +1,10 @@ +// Copyright © 2017 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: BSD-2-Clause +package rpc + +func isAddrInUse(err error) bool { + if err != nil && err.Error() == "address in use" { + return true + } + return false +} diff --git a/nfs/rpc/client_unix.go b/nfs/rpc/client_unix.go new file mode 100644 index 0000000..4b1860c --- /dev/null +++ b/nfs/rpc/client_unix.go @@ -0,0 +1,20 @@ +//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris + +// Copyright © 2017 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: BSD-2-Clause +package rpc + +import ( + "net" + "os" + "syscall" +) + +func isAddrInUse(err error) bool { + if er, ok := (err.(*net.OpError)); ok { + if syser, ok := er.Err.(*os.SyscallError); ok { + return syser.Err == syscall.EADDRINUSE + } + } + return false +}