From a8b9d369650351d0e99362fc0ddf679bdc57cff1 Mon Sep 17 00:00:00 2001 From: Ronald G Minnich Date: Tue, 3 Jun 2025 08:01:37 -0700 Subject: [PATCH] add plan9 support Signed-off-by: Ronald G Minnich --- nfs/rpc/client.go | 11 ----------- nfs/rpc/client_plan9.go | 10 ++++++++++ nfs/rpc/client_unix.go | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 nfs/rpc/client_plan9.go create mode 100644 nfs/rpc/client_unix.go 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 +}